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 ?
> 
>  .


<<winmail.dat>>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to