| This is a follow up for HHH-10610 with converted test case. Hibernate is unable to load collection mapped as follows:
@ManyToMany
@JoinTable(
name = "FirstEntity_SecondEntity",
joinColumns = @JoinColumn(name = "firstEntity_uuid"),
inverseJoinColumns = @JoinColumn(name = "secondEntity_guid", referencedColumnName = "guid"))
@Where(clause = "isLast = 1")
private Set<SecondEntity> secondEntities;
Key part of this is SecondEntity.guid not being an @Id. While loading this collection Hibernate issues query that looks like this:
SELECT
secondenti0_.uuid AS uuid1_2_0_,
secondenti0_.guid AS guid2_2_0_,
secondenti0_.isLast AS isLast3_2_0_
FROM SecondEntity secondenti0_
WHERE secondenti0_.guid = ?
For some reason this query neither contains proper entity ID nor condition from @Where annotation thus it produces HibernateException: More than one row with the given identifier was found. P.S. Same error could be achieved in all 4.x versions with additional manipulations. P.S. 2 Test case includes hacky solution to remove unique constraint on guid, I hope its ok. |