Did you have key generators for your objects? If not, then you must
manualy set ID field.

-----Original Message-----
From: Michel Bertrand [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 24, 2003 8:41 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Is it strange or not ?


Hi !

I'm having the famous org.exolab.castor.jdo.DuplicateIdentityException
problem when trying to store an object. The code fragment which causes
this error is:

if ( (frm.getDescription1() != null &&
frm.getDescription1().trim().length() > 1 ) ||
     (frm.getTitle1() != null && frm.getTitle1().trim().length() > 1) ||
     (frm.getFile1() != null ) ) {
                            
        photo = new Photo();    
        photo.setTitle(frm.getTitle1());
        photo.setDescription(frm.getDescription1());
        photo.setFile(frm.getFile1().getFileName());
        photo.setAlbumId(album.getId());
                                
        session.getDatabase().begin();
        session.getDatabase().create(photo);
        session.getDatabase().commit();

}
                        
if ( (frm.getDescription2() != null &&
frm.getDescription2().trim().length() > 1 ) ||
     (frm.getTitle2() != null && frm.getTitle2().trim().length() > 1) ||
     (frm.getFile2() != null ) ) {
                    
     photo = new Photo();       
     photo.setTitle(frm.getTitle2());
     photo.setDescription(frm.getDescription2());
     photo.setFile(frm.getFile2().getFileName());
     photo.setAlbumId(album.getId());
                                
     session.getDatabase().begin();
     session.getDatabase().create(photo);
     session.getDatabase().commit();

}

The exception happens when the second part of the code is executed. I
don't know what's happening, because I have already finished the first
transaction 
and so I would be able to start a new one, am I right ?

Thanks in advance !
Michel.
 

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

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

Reply via email to