|
Home > Archive > Apache JDO Project > June 2007 > question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Karan Malhi 2007-06-28, 7:11 pm |
| 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 L Russell 2007-06-29, 1:11 am |
| | |
| Karan Malhi 2007-06-29, 1:11 pm |
| 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:Craig.Russell@Sun.COM]
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:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
| |
| Craig L Russell 2007-06-30, 7:11 pm |
| |
|
|
|
|