How to add Distinct in Hibernate Criteria

前端 未结 8 1618
耶瑟儿~
耶瑟儿~ 2020-11-29 03:58

In my database I have a Test table, with columns: testName, testType there are 2 different tests with the same type I.e \"SUN\", so I want only one of them for which I use

8条回答
  •  醉酒成梦
    2020-11-29 04:09

    Try to use :

    cr.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    

    It work perfectly for me

提交回复
热议问题