users@glassfish.java.net

Re: Inheritance, join table and relations...

From: <glassfish_at_javadesktop.org>
Date: Tue, 13 May 2008 13:26:43 PDT

Hello,

What I think you are asking for is a way to filter to the ManyToMany relation so that what goes into the subs collection is only instances of ASub - regardless of what is actually in the database. JPA spec doesn't seem to allow it, as it seems to focus on having the data in the object model match what is in the database. Implementations might be able to handle entries in the relationtable that aren't ASub instances, but I for one would be leary of any implementation that would just silently ignore/drop them when building the object model.

Though filters can be added using provider specific code, I wouldn't recommend having your object model deviate from the database model too much. IMO it might be better to let the object model match the database by putting the collection on the superclass and use the business logic to filter/deal with any non-ASub instances.

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

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