相关配置:
<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

解决方案 »

  1.   

    sessionFactory 是要注入了没?
      

  2.   

    哎呀,来结贴了,发现还是没人气,悲剧啊,这个问题,听说不是支持注解事物管理,自己也没验证,不想验证了,对于没有session,是由于没有在sessionfaction中加入
    <prop key="hibernate.current_session_context_class">thread</prop>
    真想给自己分,哎………………