统计数量:
- sessionFactory.getCurrentSession.createCriteria(Person.class).setProjection(Projections.rowCount()).uniqueResult();
一个对象包含另一个对象的List的多表查询:
- @Entity
- public class A{
- List<B> bs;
- }
- @Entity
- public class B{
- private String name;
- }
查询:
- "sessionFactory.getCurrentSession().createCriteria(A.class).createAlias("bs",b).setFechMode("bs",FetchMode.JOIN).add(Restrictions.like("b.name","%汪云飞%")).list();