Java – distinct inner connection HQL
•
Java
I have the following hibernate entities
public class Container { ... @OneToMany private List<ACLEntry> aclEntries; }
To protect my container instance, I use the following entities:
public class ACLEntry { ... private Long sid; private boolean principal; private Integer mask; }
HQL queries will be automatically created to search container instances, @ h_ 404_ 20 @ the following query will be created:
select container from Container container inner join container.aclEntries as aclEntry with bitwise_and (aclEntry.mask,1) = 1 and (aclEntry.sid = :userId or aclEntry.sid = :roleId)
The problem is that the aclentry connection may return 2 results, which will lead to duplicate container results
Who knows how to solve this problem?
Solution
As far as I know, you need a container that can hold multiple entries of the container object. Just replace your HQL query with the following code:
Add select distinct as a native query
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码