日期:2014-05-19  浏览次数:20614 次

Annotation进行声明式事务管理不能获得session,麻烦了
相关配置:
<tx:advice id="txAdvice" transaction-manager="myTxManager"> 
<tx:attributes> 
<tx:method name="increasePrice*" propagation="REQUIRED"/> 
<tx:method name="someOtherBusinessMethod" propagation="REQUIRES_NEW"/> 
<tx:method name="*" propagation="SUPPORTS" read-only="true"/> 
</tx:attributes> 
</tx:advice>
<bean id="myTxManager" 
class="org.springframework.orm.hibernate4.HibernateTransactionManager"> 
<property name="sessionFactory" ref="sessionFactory"/> 
</bean>

具体的应用是在service层相关方法上加@Transactional注解。
在dao层用sessionfaction.getCurrentSession()获得session完成后即操作,

在运行时却报了nosession的错误,没有其他任何错误。麻烦各位了,谢谢………………
才用的是spring3&hibernate4


------解决方案--------------------
sessionFactory 是要注入了没?