Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNmE3NjE0ODMz...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16725?atlOrigin=eyJpIjoiNmE3Nj...
) HHH-16725 (
https://hibernate.atlassian.net/browse/HHH-16725?atlOrigin=eyJpIjoiNmE3Nj...
) Persisting multiple entities with one-many association and composite key with ordered
updates enabled fails (
https://hibernate.atlassian.net/browse/HHH-16725?atlOrigin=eyJpIjoiNmE3Nj...
)
Issue Type: Bug Affects Versions: 6.2.3 Assignee: Unassigned Created: 30/May/2023 10:39 AM
Priority: Major Reporter: Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Having a model:
@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;
}
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:
PropertyAccessException: Error accessing field [EntityClass.integer] by reflection for
persistent property [EntityClass#integer] : IdClass{..}
is thrown.
I will submit a PR with the test case for this.
(
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 )