1 24 package org.riotfamily.riot.hibernate.support; 25 26 import org.hibernate.Criteria; 27 import org.hibernate.Query; 28 import org.hibernate.Session; 29 import org.hibernate.SessionFactory; 30 31 39 public class HibernateSupport { 40 41 private SessionFactory sessionFactory; 42 43 public void setSessionFactory(SessionFactory sessionFactory) { 44 this.sessionFactory = sessionFactory; 45 } 46 47 public SessionFactory getSessionFactory() { 48 return this.sessionFactory; 49 } 50 51 protected Session getSession() { 52 return sessionFactory.getCurrentSession(); 53 } 54 55 protected Criteria createCriteria(Class clazz) { 56 return getSession().createCriteria(clazz); 57 } 58 59 protected Query createQuery(String hql) { 60 return getSession().createQuery(hql); 61 } 62 63 } 64 | Popular Tags |