I'm trying to use generic-dao (http://code.google.com/p/hibernate-generic-dao/ ). However, in my HibernateBaseDAO the getSession() method is implemented as sessionFactory.getCurrentSession(). This leads to an error for any entity update
org.hibernate.HibernateException: createCriteria is not valid without active transaction
However, when I use openSession() in place of getCurrentSession(), it works. I'm not using spring as a dependency in pom.xml. I've been reading on openSession() and getCurrentSession(), however still can't understand why this is happening?
Found the solution, with genericDAO it gets the current session which needs to be explicitly open using openSession(), while getCurrentSession() just attaches it to the current session. According to the author
GenericDAO makes the assumption that you will be handling transactions externally to the DAO