Posted By

skurt on 08/20/11


Tagged

grails Hibernate criteria


Versions (?)

Hibernate criteria via session in grails


 / Published in: Groovy
 

see also http://floledermann.blogspot.com/2007/10/solving-hibernate-criterias-distinct.html

  1. import com.lempa7.demandlempa.*
  2. import com.lempa7.demandlempa.enums.*
  3. import org.hibernate.Session
  4. import org.hibernate.SessionFactory
  5. import org.hibernate.criterion.*
  6.  
  7. SessionFactory sessionFactory = ctx.sessionFactory
  8. def session = sessionFactory.getCurrentSession()
  9. def criteria = session.createCriteria(TextOrder.class)
  10. //.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
  11. .setFirstResult(0).setMaxResults(5)
  12. .add( Restrictions.eq("status", TextOrderStatus.UNASSIGNED) )
  13. criteria.list()

Report this snippet  

You need to login to post a comment.