users@glassfish.java.net

JPA, entity hierarchies and Discriminator column

From: <glassfish_at_javadesktop.org>
Date: Sun, 09 Dec 2007 22:39:30 PST

If I model an entity hierarchy using a single table and a discriminator column it appears I can't have the column mapped as a field in the base entity. At least Hibernate doesn't like it. Is that a JPA restriction (I couldn't find it in the spec) or a Hibernate special behaviour?

Assuming one cannot map a discriminator column because the values are all managed by the persistence runtime how do I write a JPA query against that column? Lets say we have entities A, B, C and D all extending entity X. Now I want a query saying give me all A's or B's (but not C's or D's) satisfying something based on common fields in X. I cannot query the discriminator column as it is not mapped. So how do I express the A's or B's condition?

Thanks
[Message sent by forum member 'malm' (malm)]

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