add 子表
DetachedCriteria dc= DetachedCriteria.forClass(User.class).createAlias("addresses", "a");
dc.add(Restrictions.eq("a.doorplate","642"));
这样查出来User有重复的记录,怎么去掉重复的记录呢?
setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY),不起作用啊,
5 个解决方案
#1
DetachedCriteria dc= DetachedCriteria.forClass(User.class);
dc.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
dc.createAlias("addresses","a");
dc.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
dc.createAlias("addresses","a");
#2
试过了啊,这样不起作用
#3
高手回答一下!!!
#4
,,,,,,
#5
detachedCriteria.setProjection(Projections.distinct(Projections.property(str)));
这样可以
这样可以
#1
DetachedCriteria dc= DetachedCriteria.forClass(User.class);
dc.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
dc.createAlias("addresses","a");
dc.setResultTransformer(DetachedCriteria.DISTINCT_ROOT_ENTITY);
dc.createAlias("addresses","a");
#2
试过了啊,这样不起作用
#3
高手回答一下!!!
#4
,,,,,,
#5
detachedCriteria.setProjection(Projections.distinct(Projections.property(str)));
这样可以
这样可以