求助spring基本事物配置

allenchu發表於2006-07-03
<bean id="UserDAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="userDAO" />
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</
</props>
</property>
</bean>

<bean id="userDAO" class="net.xiaxin.dao.UserDAO">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
1.使用factory.getBean("userDAOProxy")獲得的UserDao才納入事務管理嗎?
2.使用factory.getBean("userDAO")獲得的UserDao在不在事務中?


---------------------------------------------------------------------------------------
換一種配置
<bean id="UserDAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="userDAO" />
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</
</props>
</property>
</bean>

<bean id="dataSource" class="JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/xxx</value>
</property>
</bean>
<bean id="jdbcTemplate" class="JdbcTemplate">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
<bean id="userDAO" class="net.xiaxin.dao.UserDAO">
<property name="dataSource">
<ref local="jdbcTemplate"/> <!--在資料訪問層我只使用jdbcTemplate來進行基本的操作如insert delete update select-->
</property>
</bean>

3.使用factory.getBean("userDAOProxy")獲得的UserDao納入事務管理嗎?
4.使用factory.getBean("userDAO")獲得的UserDao在不在事務中?

相關文章