criteria.setProjection(Projections.distinct(Projections.property(getIdName())));
criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
criteria.list();//此处无法返回Entity对象,而是主键的list。因为上边的setProjection
first use Criteria, not too well , who help to solve this problem ? Thank
------ Solution --------------------------------------- -----
criteria.setResultTransformer (CriteriaSpecification.ROOT_ENTITY);
modified to
criteria.setResultTransformer (Criteria.DISTINCT_ROOT_ENTITY);
------ For reference only ----------------------- ----------------
DISTINCT_ROOT_ENTITY this page will not work correctly when you return , because it is the first page to go heavy.
------ For reference only -------------------------------------- -
------ For reference only ---------------------------------- -----
not been resolved, according to the minutes .
------ For reference only -------------------------------------- -
criteria.setprojection (null) so you can remove duplicate objects ~
没有评论:
发表评论