Showing posts with label Hibernate Criteria/Query. Show all posts
Showing posts with label Hibernate Criteria/Query. Show all posts

Friday, 21 June 2013

Hibernate criteria MatchMode ANYWHERE

0 comments
The MatchMode.ANYWHERE match the pattern anywhere in the string.

criteria.add(Restrictions.like("videotags", "pattern", MatchMode.ANYWHERE));


Hibernate Criteria API (Disjunction and Conjunction)

0 comments

Criteria rootCriteria = createCriteria(entityClass);
    rootCriteria.add(Restrictions.or(
            Restrictions.eq("a","a"),
            Restrictions.and(
                    Restrictions.eq("b","b"),
                    Restrictions.eq("c","c")
            )
    ));

Friday, 24 May 2013

Delete Hibernate Criteria/Query

0 comments
Criteria
 Student student = (Student ) session.createCriteria(Student.class)
                    .add(Restrictions.eq("classId", classId)).uniqueResult();
  session.delete(student);
HQL query:
String hql = "delete from Student where classId= :classId";
session.createQuery(hql).setString("classId", classId).executeUpdate();


Related Posts Plugin for WordPress, Blogger...