最近小弟碰到一个很奇怪的问题,就是使用Spring+JPA+Hibernate+Oracle开发系统的时候,偶尔会出现数据提交不成功的问题。后台又没有报任何的错误,就是数据库没有记录。我个人怀疑是spring事务配置的问题,但是这种情况又不是经常出现。在此向各位大侠求助。谢谢!!!(
事务管理
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
</tx:attributes>
</tx:advice> <aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* *..*ServiceImpl.*(..))" />
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
</aop:config>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
DAO 继承与jpadaosupport使用的是jpadaosupport的jpatemplate模板当调用jpatemplate.persist(entity);的时候偶尔就会出现上面描述的问题了)
事务管理
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
</tx:attributes>
</tx:advice> <aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* *..*ServiceImpl.*(..))" />
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
</aop:config>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
DAO 继承与jpadaosupport使用的是jpadaosupport的jpatemplate模板当调用jpatemplate.persist(entity);的时候偶尔就会出现上面描述的问题了)
解决方案 »
- webservices接口调试问题
- 如何实现数据中心
- 求助啊,spring的同志们进来帮我看看!
- sturts2 通过ActionContext获得的request对象 和 直接通过ServletActionContext获得的request的对象是不是同一个?
- spring基本概念级疑惑 SOS!!!!!!!!!
- 安装了SQL Server2000 driver for JDBC 后要做怎样的设置才能用呢?classPath要设吗?
- Jboss-tomcat调试servlet出错误?
- 求助?
- xml spy的正式注册码?
- 这个集合遍历的时候总是同一条数据,哪位朋友有时间帮忙看下啊
- java操作数据库异常 “该语句没有返回 ResultSet”
- 急!路过的看看!
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
</tx:attributes>事务配得再精细点吧,最后的*包括前面的get*、find*了。
查一下是哪些数据没有,看看相应的方法。 <aop:pointcut id="serviceOperation" expression="execution(* *..*ServiceImpl.*(..))" />这里*..*ServiceImpl.*(..),*..*ServiceImpl怎么多了一个“.”,没用过,是不管*ServiceImpl前缀多少?