救命啊在线等 ssh事务如何配置
public void creatework(long processorid,long resourceid,Systeminfo si, Processorinfo pif, Osinfo oif,
Networkinfo nif, Monitorinfo moif, Mouseinfo muif,
Keyboardinfo kif, Memoryinfo mmif, Assetri ast, Resources rs,
Resourcecost rsc, Resourcelocation rsl, Systeminfodomain sido,
Networkdnsinfo nkif, Date acquisitiondate, Date warrantyexpiry,
Date expirydate) {
this.getHibernateTemplate().save(si);
this.getHibernateTemplate().save(pif);
this.getHibernateTemplate().save(oif);
this.getHibernateTemplate().save(nif);
this.getHibernateTemplate().save(moif);
this.getHibernateTemplate().save(muif);
this.getHibernateTemplate().save(kif);
this.getHibernateTemplate().save(mmif);
this.getHibernateTemplate().save(rs);
}
在一个创建页面中提交后要创建好几条数据 为了保存数据完整性需要配置事务,此方法 还不能分开创建,如果一个失败要全部回滚,我已经配置了 但就是不管用 望高手指点 下面是spring的配置
第一种
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 那些类那些方法使用事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* hotlong.asset.service.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
<!-- 事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="create*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
第二种
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="persist*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="remove*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="save">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="edit*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="disPlay*">PROPAGATION_REQUIRES_NEW</prop>
<prop key="changeState*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
结果都一样 有的创建成功了 有的创建失败了 在线等高手指点啊
Networkinfo nif, Monitorinfo moif, Mouseinfo muif,
Keyboardinfo kif, Memoryinfo mmif, Assetri ast, Resources rs,
Resourcecost rsc, Resourcelocation rsl, Systeminfodomain sido,
Networkdnsinfo nkif, Date acquisitiondate, Date warrantyexpiry,
Date expirydate) {
this.getHibernateTemplate().save(si);
this.getHibernateTemplate().save(pif);
this.getHibernateTemplate().save(oif);
this.getHibernateTemplate().save(nif);
this.getHibernateTemplate().save(moif);
this.getHibernateTemplate().save(muif);
this.getHibernateTemplate().save(kif);
this.getHibernateTemplate().save(mmif);
this.getHibernateTemplate().save(rs);
}
在一个创建页面中提交后要创建好几条数据 为了保存数据完整性需要配置事务,此方法 还不能分开创建,如果一个失败要全部回滚,我已经配置了 但就是不管用 望高手指点 下面是spring的配置
第一种
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 那些类那些方法使用事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* hotlong.asset.service.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
<!-- 事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="create*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
第二种
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="persist*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="remove*">
PROPAGATION_REQUIRED,-Exception
</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="save">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="edit*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="disPlay*">PROPAGATION_REQUIRES_NEW</prop>
<prop key="changeState*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
结果都一样 有的创建成功了 有的创建失败了 在线等高手指点啊
...全文
相关推荐
SSH事务配置大全
各种事物配置方法。用于工作学习都可以获得很好的知识积累
SSH的配置、事务管理和Log4j的配置
Struts1+Spring+Hibernate的整合过程,及其相关配置 事务的处理机制 Log4j的配置过程
J2EE SSH事务配置
J2EE SSH事务配置 J2EE SSH事务配置 J2EE SSH事务配置 J2EE SSH事务配置
SSH整合,纯注解,包含事务,零配置
SSH整合,纯注解,包含事务,零配置,代码高度复用
在SSH中使用事物包括SSH的搭建和配置;事务的配置;注释详细。(完整项目)
在SSH中使用事物包括SSH的搭建和配置;事务的配置;注释详细。(完整项目)


