"Bug" with JPA InheritanceType SINGLE_TABLE and key [message #1816357] |
Mon, 28 October 2019 11:13  |
Bruno DARMET Messages: 1 Registered: October 2019 |
Junior Member |
|
|
Hello, I think I've found a bug in the 2.7.5 eclipselink version : I have one table with a composite primary key (ADDRESS_TYPE, and ADDRESS_KEY). I create classes with a DiscriminatorColumn (PrivateAddress, ProfessionalAddress, etc...). When I do a query (findAll) in my PrivateAddress class, the query return a list of ProfessionalAddress because the rows {{PRIVATE, 1} and {PROFESSIONAL, 1}} both exist. This bug occurs (for me) because the org.eclipse.persistence.internal.descriptors.ObjectBuilder loads primaryKeyFields from this.descriptor.getPrimaryKeyFields() (line 3095) without taking the DiscriminatorColumn, so for this table, with only ADDRESS_KEY as primary key, jpa found the wrong object.
I can send you my code if needed.
Thank's for your help, and please forgive my english : I'm french. ;-)....
|
|
|
Re: "Bug" with JPA InheritanceType SINGLE_TABLE and key [message #1816395 is a reply to message #1816357] |
Tue, 29 October 2019 01:47  |
Chris Delahunt Messages: 1389 Registered: July 2009 |
Senior Member |
|
|
You would have to show how you've mapped your primary key, but it seems like you might have only specified the ADDRESS_KEY as the ID for the hierarchy.
Having the Type be part of a composite primary key is not usual - all your foreign keys to that table are going to have to specify both the key and the type; something that could be avoided if you had a unique column in the table for the ID.
[Updated on: Tue, 29 October 2019 01:48] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01876 seconds