users@glassfish.java.net

Re: Implementing Joined Inheritance in JPA

From: <glassfish_at_javadesktop.org>
Date: Wed, 23 Jul 2008 07:21:59 PDT

Hello,

I'm not sure of the problem you are trying to solve, but there must be other acceptable ways (I hope). If one user using/modifying and existing parent object while another user wishes to turn it into a child object, how would you expect the object identity to be maintained? Parent entities cannot morph into child entity objects in java, so it would require first deleting the parent object and then creating a new Child object with the same id. Since you don't want a descriminator field, you would likely need to have the two classes share the parent table (JPA requires the descriminator field for inheritance), and so this would be error prone and very sensitive to insert/delete orders.

My suggestion would be to instead have the parent or child class reference the other with a One to one relation, and traversed this relation to get the parent (or child) values.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

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