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/hibernate-orm/pull/6695|smart-link] ). |
|