Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

Gordon Yorke

Greenhorn
+ Follow
since Nov 16, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gordon Yorke

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.

--Gordon
You are getting the same Entity instance because you are querying for the Id = 1 in all three queries. Each entity instance in the hierarchy needs its own Id.
--Gordon
The PK must be writable or use IDENTITY sequencing.
The PK must be writable or use IDENTITY sequencing. What is the error you are seeing.
Are you using a static import for the enum? perhaps try
How is the ID generated? If it is generated by the database column (ie an identity field) then use:
And what does the following do?


How is the ServerSession created by your framework?
12 years ago