org.hibernate.HibernateException: load is not valid without active transaction
I am getting the following error while load a user data.
org.hibernate.HibernateException: load is not valid without active transaction
I am using AspectJ compile time weaving and spring 3.O. and Hibernate 3.0
Below is my code and configuration file.
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public boolean add(User user) {
getUser(user)
}
public User getUser(User user) {
Session session = this.getSession();
User user = ( User ) session.load(User.class, 130);
return user;
}
Configuration:
<bean id="hbSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
<开发者_StackOverflow中文版;/property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
</bean>
<!-- Initializes Transaction manager to handle hibernate transactions -->
<bean id="hbTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="hbSessionFactory" />
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="hbTxManager"/>
Thanks in advance
精彩评论