日期:2014-05-20 浏览次数:20798 次
<!-- JPA Transaction manager :JPA事务控制设置--> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> <property name="dataSource" ref="dataSource"/> </bean> <aop:config> <aop:pointcut id="crudMethods" expression="execution(* org.sshdemo.service.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="crudMethods"/> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save" propagation="REQUIRED"/> <tx:method name="update" propagation="REQUIRED"/> <tx:method name="delete" propagation="REQUIRED"/> </tx:attributes> </tx:advice>
------解决方案--------------------
hibernate底层其实还是用的JDBC,所以事务边界是少不了的。除非你用SPRING去做事务管理