This one time, at band camp, qwam swatidi said: qs>I'm working on a web based application, and I have a question regarding how qs>I can use the persistence features of castor. qs> qs>To explain... qs> qs>The user logs on onto the application and their details are loaded from the qs>database and stored in their session. (NB: The User class implements qs>Timestampable). See code listing 1. qs> qs>At some point the user decides to write a note on a specific client. The qs>note is attached to the client and also includes details about the current qs>user that submitted the note. See code listing 2. NB: A client can have a qs>collection of notes each which refer to the particular user that created qs>them. qs> qs>My problem is that when this code is commited, a new note is created for the qs>client and it also creates a new copy of the User. This is not the desired qs>behaviour that I'm after. I want it to use the users information and make an qs>association between the two. Not create another copy of it. qs> qs>-> What should I do to solve this elegantly? qs> qs>I've tried initially loading the user using Database.Exclusive. i.e. qs> qs>user = db.load(User.class, new Integer(1), Database.Exclusive); qs> qs>But that doesn't seem to work. qs> qs>If in the second code listing, qs> qs>I perform a db.update(user) on the user before retrieving the client's qs>details it works but it doesn't seem very elegant/correct to do this.
This is how Castor JDO's long transactions (http://www.castor.org/long-transact.html) are designed to work. The call to db.update( user ) makes the second transaction context aware of the User instance. You already found the solution to your problem. 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
