Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 查询getResultList返回重复_Java_Hibernate - Fatal编程技术网

Java 查询getResultList返回重复

Java 查询getResultList返回重复,java,hibernate,Java,Hibernate,使用Query.getResultList()返回重复数据时遇到问题。我还做了一些研究,发现我们需要设置结果变压器(Criteria.DISTINCT\u ROOT\u ENTITY)。它工作得很好 但是,在hibernate 5.2中不推荐使用这种方法,我们使用的是hibernate 5.2.8,所以有其他方法可以做到这一点吗 更新1:我正在使用HQL。查询如下所示: 从用户实体中选择u u left join fetch u.profile p left join fetch p.roles

使用
Query.getResultList()返回重复数据时遇到问题。我还做了一些研究,发现我们需要
设置结果变压器(Criteria.DISTINCT\u ROOT\u ENTITY)
。它工作得很好

但是,在hibernate 5.2中不推荐使用这种方法,我们使用的是hibernate 5.2.8,所以有其他方法可以做到这一点吗

更新1:我正在使用HQL。查询如下所示:
从用户实体中选择u u left join fetch u.profile p left join fetch p.roles r left join fetch r.roleFunction

使用typedquery而不是问题。在最新的hibernate中,类型化查询为getresultlist或getsingleresult提供了许多选项…

您的查询是什么?这是一个标准查询吗?使用distinct select如何?我刚刚更新了我的问题,谢谢你的提问
从用户实体中选择distinct u left join fetch u.profile p left join fetch p.roles r left join fetch r.roleFunction
工作吗?请用你的全部代码更新你的问题,包括
查询
定义。