users@glassfish.java.net

Re: Basic JPA Question

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 02:12:12 PDT

I think a solution where the primary key of the children is composed by its parents id and its own id is an viable solution. This would of course mean that you have to create a primary key class for the child entity.

You could also just have a generated id for the children which is only used as a primary key. Then you can just assign any "real" id to each child. One problem with this solution is that you won't be able to add a constraint for the "real" id to ensure that it is unique.

Examples of children table:

-------------------------------
| [b]id[/b] | [b]parent_id[/b] | value |
-------------------------------
or
------------------------------
| [b]id[/b] | child_id | value |
------------------------------

pk in bold
[Message sent by forum member 'woel' (woel)]

http://forums.java.net/jive/thread.jspa?messageID=240854