Whats the ... in your second transaction? Do you load he user in there or use the one from up above? Also, does role have a Vector of users in it? if so you could loading the user already when you go to load the roles. Trying taking out the db.update and see if that works.
-Nick On Tue, 7 Dec 2004 23:21:43 +0100, Markus Sell <[EMAIL PROTECTED]> wrote: > Hi, > > i have the following scenario: > 1) a user is working for different customers and has different roles. > 2) 3 objects exists: User, Customer and Roles. > User: > public class user implements Persistent, TimeStampable { > Vector cvct_Roles; > Vector cvct_Customer; > ... > public Vector getRoles() { > return cvct_Roles; > } > > public void setRoles(Vector roles) { > cvct_Roles = roles; > } > > public void addRoles(Roles role) { > if (!cvct_Roles.contains(role)) { > cvct_Roles.addElement(role); > role.addUser(this); > } > } > > ... > } > The Role object class look simular. > > 3) relationships: user - customer (n:m) in table user2customer, user - roles > (n:m) in table user2role > 4) in the mapping file i'm using the "many-table" statement > > If I create a new User with new Customer or Role assignments it works > perfectly. If I try to update an existing User by adding a new Role, I get > the exception: > org.exolab.castor.jdo.DuplicateIdentityException: update object which is > already in the transaction > at > org.exolab.castor.persist.TransactionContext.markUpdate(TransactionContext.java:995) > at > org.exolab.castor.persist.TransactionContext.update(TransactionContext.java:1074) > at > org.exolab.castor.jdo.engine.DatabaseImpl.update(DatabaseImpl.java:378) > > I'm using long transaction to do the update the user object. > > .. > db.begin(); > User ldbp_User = (User)db.load(User.class, userkey); > db.commit(); > .. > db.begin(); > .. > for (int lint_Index = 0; lint_Index < roles.size(); lint_Index++) { > Role ldbp_Role = (Role)db.load(Rol.class, > ((Integer)roles.getlint_Index)).intValue()); > ldbp_User.addRoles(ldbp_Role); > } > db.update(ldbp_User); > db.commit(); > > Any ideas? Do I have to load the Role Object in the first Transaction? Use > Autostore? > > thanks, > markus > > > ----------------------------------------------------------- > 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