The hierarchy was designed like that on purpose, they all share the same ID. Why should they need their own IDs? If that's the way you design your DB, well, you're just putting redundancy into your DBs which is not what I'm going to do...
An ORM should really handle this model. If I query an ID for different classes, I want the ORM to return just that class' entity and not some super type. If I call it onto an abstract class, the ORM should return the nearest sub entity, if a discriminator is set or null if not.
Joined: Nov 16, 2009
I think there are a couple issues here.
First the two 'successful' queries should be returning the same instance because you are querying for the same object. Queries in JPA are always Polymorphic if the class type is a member of a mapped inheritance hierarchy. Users map inheritance because they want to take advantage of polymorphic queries. Each Entity in the hierarchy gets its own Id not because of redundancy but because without it the finders would not be polymorphic as there would be multiple instances in the same hierarchy with the same Id and these instances would be ignored. If you do not want polymorphic queries then do not map the inheritance simply add the subtables as secondary tables. You will have to ensure you are using some identifier to make the entries in the root table unique.
Second, there does seem to be a bug in EclipseLink, that third query should have returned null. You should file a bug report for that.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: EclipseLink inheritance bug?: super class instantiated instead of sub class