Hi,
I'm using hibernate-5.2.1-JPA2.1 via openejb-core-7.0.1 in Java SE 8 with Postgresql 9.5.4 env.
I have a 1 (BuddyRelation) :n (BuddyPermission) Relation
The query
Code:
SELECT br FROM BuddyRelation br LEFT JOIN FETCH br.buddyPermissions WHERE br.account.accountId = :accountId
returns not only the distinct BuddyRelations but a row for each 1:n BuddyPermission.
I would have expected that only the distinct BuddyRelation entries are returned, with properly filled buddyPermissions Map.
Code:
class BuddyRelation
...
@OneToMany(mappedBy = "buddyRelation", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@OrderBy("permission ASC")
@MapKey(name = "permission")
@OnDelete(action = OnDeleteAction.CASCADE)
public Map<String, BuddyPermission> getBuddyPermissions() {
return buddyPermissions;
}
...
}
What is wrong?
Thanks
Marcel