This one time, at band camp, Markus Garscha said:

MG>i need long transaction because i work with tomcat (and struts) to
MG>manage the customer over web.
MG>
MG>i generate a "p = new Phone()"
MG>
MG>i generate an arraylist with all PhoneTypes and represent them in a
MG>dropdownlist, so the user can choose one of the PhoneTypes.
MG>
MG>then i take the selected PhoneType and put in the new Phone instance.
MG>
MG>then i add the complete Phone to my Person ( person.add(p)) an try to
MG>call a db.update(person) i get an exception:
MG>
MG>org.exolab.castor.jdo.DuplicateIdentityException: update object which is
MG>already in the transaction
MG>        at
MG>org.exolab.castor.persist.TransactionContext.markUpdate(Unknown Source)
MG>        at org.exolab.castor.persist.TransactionContext.update(Unknown
MG>Source)
MG>        at org.exolab.castor.jdo.engine.DatabaseImpl.update(Unknown
MG>Source)
MG>
MG>can anyone help???
MG>isn't it really strange?
MG>
MG>if i change the PhoneType of an existing Phone-Entry it works fine!
MG>
MG>any sugestions? links? help????

Markus,

It's difficult for me to tell exactly because you didn't post the
client code, but it would seem to me that in the space of the
transaction, the object has already been loaded.

The following example illustrates the incorrect use of Castor and
would cause the DuplicateIdentityException to be thrown:

    db.begin();
    Person person = new Person();
    Phone phone = new Phone();
    person.addPhone( phone );
    ...
    db.update( person );
    db.commit();

The following example illustrates the correct use of Castor and
will not throw the exception:

    db.begin();
    Person person = new Person();
    Phone phone = new Phone();
    person.addPhone( phone );
    ...
    db.commit();

Note that the second example does not use db.update() because this
is a short transaction.

Hope this helps.

Bruce
--

perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

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

Reply via email to