views:

232

answers:

1

Is it possible for a Primary Key of an nested Entity to be used as the Primary Key of the Nest Entity?

For Example:

If I had a Entity 'Staff' who has a primary key 'EID' and has the nested Entity 'Job'. The Entity 'Job' has a primary key 'JID', and a Discriminator type 'DTYPE' so that sub classes of Job may be stored in the DTYPE along with their various columns. I would like the primary key EID to be identical to JID for each different job added to my Staff table. Is this possible?

Or is this not allowed as 'Job' could be null, thus no JID could be mapped to be a primary key?

Is there a better way to model this?

A: 

You mean "Compound Identity" ? This is part of JPA2, so available if your implementation supports it, which DataNucleus does.

--Andy (DataNucleus)

DataNucleus