Thanks Craig, Some more follow up questions. "Anyway, the implementation is required to actually assign an id only at the point in time when you either flush the instance or ask for the object id via getObjectId. Once assigned, the id won't change." so if I do pm.makePersistent(obj); Object objectid = pm.getObjectId(obj); I am assuming JDO will assign this object an ID. lets say it is 10 What happens if I rollback the transaction? Also, what happens if before I commit, some other tx uses 10 and inserts a row When I commit, will i get an exception? This would be somewhat unexpected I guess, so I think I did not understand it properly "The assignment of the object id depends to a large extent on the user's metadata for the class. Several strategies can be used." Where exactly in the metadata do I specify this? Thanks for the help Regards
Karan Singh ________________________________ From: Craig L Russell [mailto:[EMAIL PROTECTED] Sent: Thu 6/28/2007 8:34 PM To: Apache JDO project; JDO Expert Group Subject: Re: question Hi Karan, In JDO, an object id is like Schroedinger's cat [1]. You don't know what it is until you ask for it, or the implementation needs it. This is because in many cases, you need to round trip to the database to create the id and it's more efficient if you can defer the database trip until the transaction commits. Anyway, the implementation is required to actually assign an id only at the point in time when you either flush the instance or ask for the object id via getObjectId. Once assigned, the id won't change. Of course, there's nothing to stop the implementation from eagerly assigning the id during the makePersistent call. The assignment of the object id depends to a large extent on the user's metadata for the class. Several strategies can be used. Craig [1] http://en.wikipedia.org/wiki/Schrödinger's_cat On Jun 28, 2007, at 1:50 PM, Karan Malhi wrote: > Does a persistent-new object have an objectID. If yes, then what is > the value stored in that? How does JDO determine what value to store > in it? > > -- > Karan Malhi Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
