Hibernate Criteria Left Join


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public List<Item> findBySectionId(Integer sectionId) {
  2. return getCurrentSession().createCriteria(Item.class, "i")
  3. .createAlias("i.sections", "s", Criteria.LEFT_JOIN)
  4. .add(Restrictions.eq("s.id", sectionId))
  5. .list();
  6. //
  7. // return getCurrentSession().createQuery("select distinct i from Item i left join i.sections s where s.id=:id")
  8. // .setParameter("id",sectionId).list();
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.