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:
is thrown. I will submit a PR with the test case for this. |