|
<!-- 目標對象 -->
<bean id="deptDao" class="com.morris.school.dao.jdbc.DepartmentDapImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 切面 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 公用事務代理 -->
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true" lazy-init="true">
<!-- 切面 -->
<property name="transactionManager" ref="transactionManager"></property>
<!-- 屬性模板 -->
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="do*">PROPAGATION_REQUIRED</prop>
<prop key="query*">readOnly</prop>
<prop key="find*">readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
<!--
PROPAGATION_REQUIRED == 支援當前事務,如果當前沒有事務則重新建立一個事務。
PROPAGATION_SUPPORTS == 支援當前事務,如果當前沒有事務則以非事務方式執行 readonly ==
就是唯讀,設定作業許可權為唯讀,一般用於查詢
-->
</props>
</property>
</bean>
<bean id="userDaoProxy" parent="baseTransactionProxy">
<property name="target" ref="deptDao"></property>
</bean> |