Spring Transaction
下面是在Spring 2 + Hibernate 3 + MySQL 5架構中使用無Transaction的設定檔(XML)
<bean id="individualMgnt" class="component.IndividualMgnt">
<property name="individualDao" ref="individualDao"/>
<property name="individualPartyDao" ref="individualPartyDao"/>
<property name="locationDao" ref="locationDao"/>
<property name="partyDao" ref="partyDao"/>
<property name="roleDao" ref="roleDao"/>
</bean>
下面是在Spring 2 + Hibernate 3 + MySQL 5架構中使用Spring Transaction的設定檔(XML)
<bean id="individualMgnt"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<bean class="component.IndividualMgnt">
<property name="individualDao" ref="individualDao"/>
<property name="individualPartyDao" ref="individualPartyDao"/>
<property name="locationDao" ref="locationDao"/>
<property name="partyDao" ref="partyDao"/>
<property name="roleDao" ref="roleDao"/>
</bean>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">
PROPAGATION_REQUIRED, ISOLATION_READ_COMMITTED, timeout_30, readOnly
</prop>
<prop key="add*">
PROPAGATION_REQUIRED, ISOLATION_READ_COMMITTED, timeout_-1, -MyException
</prop>
<prop key="remove*">
PROPAGATION_REQUIRED, ISOLATION_READ_COMMITTED, timeout_-1, -MyException
</prop>
</props>
</property>
</bean>
0 意見:
張貼留言