This is a follow up for [HHH-10610] with converted test case.
Hibernate is unable to load collection mapped as follows:
{code:java} @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; {code} *Key part here is _SecondEntity.guid_ not being an _@Id_*.
While loading this collection Hibernate issues query that looks like this:
{code:sql} 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 = ? {code}
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 can be achieved in all 4.x versions with additional manipulations. P.S. 2 Test case includes hacky solution to remove generated unique constraint on _guid_, I hope its ok. |
|