I am using Hibernate3 with Spring 3. I am trying to start hibernate transaction using Spring. Given below is my configurations
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
I am getting the following error while running the application.
HibernateException: get is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:341)
I have the following line in hibernate config xml
<property name="hibernate.current_session_context_class">thread</property>
The code which uses hibernate transaction is:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Book book = (Book)session.get(Book.class, id);
What could be wrong in this? Is the value for current_session_context_class is anything other than thread?