Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNTgyZmI5MTU1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16725?atlOrigin=eyJpIjoiNTgyZm...
) HHH-16725 (
https://hibernate.atlassian.net/browse/HHH-16725?atlOrigin=eyJpIjoiNTgyZm...
) Persisting multiple entities with one-many association and composite key with ordered
updates enabled fails (
https://hibernate.atlassian.net/browse/HHH-16725?atlOrigin=eyJpIjoiNTgyZm...
)
Change By: Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Having a model:
{code:java}@Entity
@IdClass(IdClass.class)
class EntityClass {
@Id
private String string;
@Id
private int integer;
@ManyToOne
private EntityClass parent;
@OneToMany(mappedBy = "parent")
private List<EntityClass> children = new ArrayList<>();
}
class IdClass {
private String string;
private int integer;
}{code}
and setting {{hibernate.order_updates}} set to {{true}} leads to an exception when
multiple entities of such type are persisted within the same transaction.
The problem is caused by {{ExecutableList#add()}}. Since the setting requires sorting,
adding a new action tries to call compare method to see if sorting is required. But since
the entity is using a composite ID the {{VirtualIdEmbeddable#compare()}} is called with
{{IdClass}} instances passed into it, while {{getAttributeMappings()}} returns the
attributes of {{EntityClass}} as a result:
{noformat}PropertyAccessException: Error accessing field [EntityClass.integer] by
reflection for persistent property [EntityClass#integer] : IdClass{..}{noformat}
is thrown.
I will submit a PR with the test case for this ([
https://github.
com/hibernate/hibernate-orm/pull/6695|https://github.com/hibernate/hibern...]
).
(
https://hibernate.atlassian.net/browse/HHH-16725#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16725#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:d82e018 )