users@glassfish.java.net

Re: Basic JPA Question

From: <glassfish_at_javadesktop.org>
Date: Wed, 17 Oct 2007 18:36:02 PDT

The child object has an ID but it is NOT unique to objects contained in other objects.

For example, let's say Server "A" has a list of CPU's containing CPU's with ID's "1" and "2". Another Server, "B", also has a list of CPU's which also contains CPU's with ID's "1" and "2".

So, according to the JPA, the CPU's are entities and, therefore, must have globally unique ID's amongst all other CPU's....not just unique to the parent containing them.

----
As far as merging goes, from what I have seen, let's say you persist Server "A", above  The child entities, CPU's with ID's "1" and "2" are also persisted to the database.  If I want to update Server "A", but now it only has 1 single child CPU, with ID "3", if I did a simple merge, I would have CPU "1", "2", and "3" in the database instead of just having CPU "3" like I intended.
---
Lastly, If I have, say, 1,000 systems each with 1,000 children and I have to do an update, once a day, that's 1,000,000 potential unique identifiers that must be generated every day.  Doesn't that seem unmaintainable?  Also, it seems that there would be a better way, but maybe I haven't played around with this that much yet...
Thanks for helping so far, Marina.  I'm really trying to understand this JPA stuff ;)
[Message sent by forum member 'wfsaxton' (wfsaxton)]
http://forums.java.net/jive/thread.jspa?messageID=240816