1 先保存一个对象,比如一个job对象。
2 取的刚保存完成的job对象的id,放到另外一个对象的属性中,也可能是N属性对象组成的LIST。
为了保持数据一致性,如何配置这个事务?用注释最好。
[b]问题补充:[/b]
开发环境:[color=red]Struts2 + Spring2.5.6 + Hibernate3.2.0.ga[/color]
[b]问题补充:[/b]
谢谢大家的支持,这30分给谁呢?平均分配吧,网站不支持。你俩商量一下,给我个决定。
我还是倾向于用注释来解决这个问题。
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* com.incesoft.security.acegi.logic.service.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>
<aop:advisor pointcut="execution(* com.incesoft.business.maintain.service.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>
<aop:advisor pointcut="execution(* com.incesoft.business.manage.service.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="load*" read-only="true"/>
<tx:method name="search*" read-only="true"/>
<tx:method name="*" />
<tx:method name="*Faq*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
<tx:method name="*faq*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
<tx:method name="*Chat*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
<tx:method name="*chat*" no-rollback-for="com.incesoft.business.commons.ServiceException"/>
</tx:attributes>
</tx:advice>
你应该是用spring+hibernate做的的吧
多加点分,我把代码配置文件打包发给你一份
根据你具体的类,自己改一下
发给你个例子,看着改改方法名,放在你的配置文件中就能用了
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource" />
aop:config
expression="execution(* com.pet.service.impl.ServiceImpl.*(..))" />
/aop:config
tx:attributes
rollback-for="Exception" />
rollback-for="Exception" />
rollback-for="Exception" />
/tx:attributes
/tx:advice
你所说的注释是用注解来进行事务处理是吗?
给huangnetian (架构师)吧,毕竟是他先回答的你。