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 是要注入了没?
阅读
上一篇:hibernate sqlQuery 与实体类的映射关系有关问题 下一篇:返回列表