以下是我的配置事务管理器,问题是在同一个类中只有saveOrUpdateAll方法可以提交事务,update ,delete,insert方法都不可以提交事务,请高手求救啊 好郁闷 遇到这样问题 我声明的方法都没错啊 为什么不能提交呢<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="saveOrUpdateAll*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.service.Impl.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
</beans>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="saveOrUpdateAll*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.service.Impl.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
</beans>
解决方案 »
- 我有些强迫症,看到==或!=我就想不通
- struts2.0中的AJAX表单提交的方式处理
- 请问JAVA WEB START的界面可以修改的嘛?
- java byte bit基础问题
- JSP批量操作?
- 面试题
- 请教各位大侠了,我的毕业设计是<基于Web Services的教学网站>,我是一头雾水!
- 大家觉得外包到ibm公司去做测试,怎么样?
- 看过-<JBuilder7&Weblogic7整和开发培训手册>高手请进!
- eclipse 中运行jsp 点击链接报错 大神帮忙看下
- {关于几个专业术语的问题包括(JS,JSON,SSH,AJAX,Jquery)}
- 你的就是我的 - 散分100 - 先谢谢各位大虾
<tx:method name="saveOrUpdateAll*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
方法名写对了吗?
有没有报错误啊?
package com.service.Impl;import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Set;import com.abstr.service.AbstrServiceOrdersDetail;
import com.dao.Interface.IBaseDao;
import com.model.Orders;
import com.model.OrdersDetail;
import com.service.Interfacce.IBaseService;public class OrdersDetailServiceImpl extends AbstrServiceOrdersDetail {
private IBaseDao ibaseOrdersDetailDao;
private IBaseDao<Orders,Integer> ordersDao; public void delete(OrdersDetail entiyObj) {
// TODO Auto-generated method stub
} public List findAll() {
// TODO Auto-generated method stub
return null;
} public OrdersDetail findById(Integer id) {
// TODO Auto-generated method stub
return (OrdersDetail)ibaseOrdersDetailDao.findById(id);
} public Integer insert(OrdersDetail entiyObj) {
// TODO Auto-generated method stub
return ibaseOrdersDetailDao.insert(entiyObj);
} public void update(OrdersDetail entiyObj) {
// TODO Auto-generated method stub
ibaseOrdersDetailDao.update(entiyObj);
}
// public void saveOrUpdateAll(Collection<OrdersDetail> c, Object obj)
public void saveOrUpdateAll(Collection<OrdersDetail> c,Object orders){
for(OrdersDetail detail:c){
detail.setOrders((Orders)orders);
}
ordersDao.insert((Orders)orders);
ibaseOrdersDetailDao.saveOrUpdateAll(c);//以多的一端插入
}
public IBaseDao getIbaseOrdersDetailDao() {
return ibaseOrdersDetailDao;
} public void setIbaseOrdersDetailDao(IBaseDao ibaseOrdersDetailDao) {
this.ibaseOrdersDetailDao = ibaseOrdersDetailDao;
} public IBaseDao<Orders, Integer> getOrdersDao() {
return ordersDao;
} public void setOrdersDao(IBaseDao<Orders, Integer> ordersDao) {
this.ordersDao = ordersDao;
} }
就是执行service层update方法后 数据库不会更新
但是再执行service层saveOrUpdateAll方法后 前面的执行的update方法数据库里的数据立刻更新 同时也更新saveOrUpdateAll后的数据