Follow the below to overcome Current transaction is not in progress exception:
this.getSessionFactory().openSession().createCriteria(Project.class);
Dont use the following if you are experiencing the above exception:
this.getSessionFactory().getCurrentSession().createCriteria(Project.class);
Else you can also use the following also:
this.getSessionFactory().openSession().createCriteria(Project.class);
Dont use the following if you are experiencing the above exception:
this.getSessionFactory().getCurrentSession().createCriteria(Project.class);
Else you can also use the following also:
Session session = ModelManager.getInstance().getCurrentSession();
Transaction tx = null;
List<Actor> studentList= null;
try {
tx = session.beginTransaction();
Criteria criteria = session.createCriteria(Student.class);
criteria.add( Restrictions.like("name", "A%") );
actorList = criteria.list();
tx.commit();
} catch (HibernateException he) {
tx.rollback()
}
No comments:
Post a Comment