Hello Patrick,
As I answered to Marco, if my example is simple, the real code is not so
simple!
The program - which is running alone - tries to upgrade the content of a
database which contents application parameters (a new version of the
application will bring many new objects in different "tables", and
modification in some existing objects).
The process may be long, and in fact when we need to read the object, we
have not anymore the object's reference: we have only keywords to retrieve
it from database by an oql query.
If, in the example, I use directly jdbc, and not jdo, the query retrieves
the new object.
You said OQL doesn't go through the cache: that what I thought first, but if
I try the same thing while modifying an existing object, my oql query
retrieves the modified object!
db.begin();
log.info("Object read via oql ");
ArrayList lesDossiers = RequetesJdoAssure.getLesDossiers("GALO", "%", "%",
"%", db);
for (Iterator iter = lesDossiers.iterator(); iter.hasNext();) {
Dossier element = (Dossier) iter.next();
log.info(" Nom = " + element.getNomPatronymique() + " - Pr�nom = " +
element.getPrenom());
log.info(" Modif du pr�nom");
// The object is modified
element.setPrenom("TOTO");
}
log.info(" Object is read again via oql ");
lesDossiers = RequetesJdoAssure.getLesDossiers("GALO", "%", "%", "%", db);
for (Iterator iter = lesDossiers.iterator(); iter.hasNext();) {
Dossier elementModifie = (Dossier) iter.next();
log.info(" Nom Apres modif = " +
elementModifie.getNomPatronymique() + " - Pr�nom apr�s modif = " +
elementModifie.getPrenom());
}
So I'm little lost !
Sylvie.
___________________
CREDI RA
Sylvie Palluel
[EMAIL PROTECTED]
___________________
> -----Message d'origine-----
> De�: Patrick van Kann [mailto:[EMAIL PROTECTED]
> Envoy�: mardi 9 novembre 2004 14:19
> ��: [EMAIL PROTECTED]
> Objet�: RE: [castor-dev] [jdo] Reading, in the same transaction, a data
> just created (reading via oql query)
>
> Sylvie,
>
> Your object won't be in the database until you call commit. Because OQL
> doesn't go through the cache, it won't find anything unless it is in the
> database.
>
> Why do you no longer have the ID? Surely you can get this from the object
> after create()?
>
> Cheers,
>
> Patrick
>
>
> -----Original Message-----
> From: SYLVIE PALLUEL [mailto:[EMAIL PROTECTED]
> Sent: Tue 11/9/2004 12:43 PM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] [jdo] Reading, in the same transaction, a data
> just created (reading via oql query)
>
> Sorry!
> Here's the complete message ...
>
> Hi,
>
> In a transaction (between the db.begin() and the db.commit()), I'm
> creating
> a new object A .
> And then, far away in the code, but in the same transaction, I need to
> read
> again the object A to create another object B.
> To do this, as I have no longer the id, I'm usinq an oql query to retrieve
> A... But it is not found...
> What can I do (castor configuration or special command) to be able to read
> it by an oql query ?
>
>
> db.begin();
>
> log.info(" Creating object dossier via jdo ");
> Dossier dossierAjoute = new Dossier();
> dossierAjoute.setNomPatronymique("LEGRAND");
> dossierAjoute.setPrenom("ALEXANDRE");
> dossierAjoute.setCivilite("M");
> dossierAjoute.setNumNatident("11111111111");
>
> db.create(dossierAjoute);
>
>
> log.info(" Reading back the object just created via jdo "); lesDossiers =
> RequetesJdoAssure.getLesDossiers("LEGRAND", "%", "ALEXANDRE", "%", db);
> log.info(" Nbre de dossiers = " + lesDossiers.size()); // The result will
> be
> 0 ... for (Iterator iter = lesDossiers.iterator(); iter.hasNext();) {
> Dossier element = (Dossier) iter.next();
> log.info(" Nom Apres creation = " + element.getNomPatronymique() + "
> - Pr�nom apr�s creation = " + element.getPrenom()); }
>
> // if I had the object if I could do this ...
> log.info(" Reading back the object by db.load() ");
> Dossier dossier=(Dossier)
> db.load(Class.forName("fr.cnam.scapin.metier.donnees.dossiers.Dossier"),
> new
> Integer(dossierAjoute.getIdDossier()));
> // this will be ok
> log.info("Dossier relu par db.load " + dossier.toString());
>
> db.rollback();
>
>
>
> Thanks for your help.
>
> Sylvie
> ___________________
> CREDI RA
> Sylvie Palluel
>
> [EMAIL PROTECTED]
> ___________________
>
>
> > -----Message d'origine-----
> > De : SYLVIE PALLUEL [mailto:[EMAIL PROTECTED]
> > Envoy� : mardi 9 novembre 2004 13:23
> > � : [EMAIL PROTECTED]
> > Objet : [castor-dev] [castor-user][jdo] Reading, in the same
> transaction,
> > a data just created (reading via oql query)
> >
> > Hi,
> >
> > In a transaction (between the db.begin() and the db.commit()), I'm
> > creating
> > a new object A .
> > And then, far away in the code, but in the same transaction, I need to
> > read
> > again the object A to create another object B.
> > To do this, as I have no longer the id, I'm usinq an oql query to
> retrieve
> > A... But it is not found...
> > What can I do (castor configuration or special command) to be able to
> read
> > it by an oql query ?
> >
> > .
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev