日期:2014-05-19 浏览次数:20764 次
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <aop:config> <aop:pointcut id="daoMethods" expression="execution(* com.neusoft.leehom.service.impl.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="get*" propagation="REQUIRED" read-only="true"/> <tx:method name="query*" propagation="REQUIRED" read-only="true"/> <tx:method name="*" propagation="REQUIRED" read-only="true"/> </tx:attributes> </tx:advice>
public void insertEmp(Emp emp){ empDao.save(emp); }
public void save(Emp transientInstance) { log.debug("saving Emp instance"); try { Session session = getSession(); session.save(transientInstance); log.debug("save successful"); } catch (RuntimeException re) { log.error("save failed", re); throw re; } }
<property name="sessionFactory" ref="sessionFactory"/> 并外建议把<tx:advice>配置到<aop:config>前面。
------解决方案--------------------
弄个断点,debug下,看看有值没有
------解决方案--------------------
advice换成自己的一个方法,输出日志,看看是否执行