Criteria instance - I
31 August 2008Hibernate provides an interface org.hibernate.Criteria, which represents a query against a particular persistent class.
Review the following example:
Criteria crit = session.createCriteria(Student.class); crit.setMaxResults(50); List students = crit.list();
Resultset can be narrowed according to requirement. The class org.hibernate.criterion.Restrictions defines factory methods for obtaining certain built-in Criterion types.
List students = sess.createCriteria(Student.class) .add( Restrictions.like("name", "Laiq%") ) .add( Restrictions.between("age", minAge, maxAge) ) .list();
continued …
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Criteria instance - I