jinfeng_wang

G-G-S,D-D-U!

BlogJava 首页 新随笔 联系 聚合 管理
  400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks

Spring Transaction:通过Template+Callback机制,实现对各种事务的统一封装。

 

<bean id="transactionManager" //JDBC Transaction的封装

       class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

       <property name="dataSource">

              <ref bean="dataSource"/>

       </property>

</bean>

 

<bean id="transactionManager" //Hibernate事务的封装

       class="org.springframework.orm.hibernate.HibernateTransactionManager">

       <property name="sessionFactory">

              <ref bean="sessionFactory"/>

       </property>

</bean>

 

<bean id="transactionManager"//JDO事务的封装

       class="org.springframework.orm.jdo.JdoTransactionManager">

       <property name="persistenceManagerFactory">

              <ref bean="persistenceManagerFactory"/>

       </property>

</bean>

 

<bean id="transactionManager" //JTA 事务的封装

       class="org.springframework.transaction.jta.JtaTransactionManager">

       <property name="transactionManagerName">

              <value>java:/TransactionManager</value>

       </property>

</bean>

 

<bean id="courseService"//利用AOP,将TransactionManager和普通的Service编织起来,实现事务。

       class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

       <property name="proxyInterfaces">//编织后对外的接口

              <list>

                     <value>com.springinaction.training.service.CourseService</value>

              </list>

       </property>

       <property name="target">//目标

              <ref bean="courseServiceTarget"/>

       </property>

       <property name="transactionManager">//植入的事务管理者

              <ref bean="transactionManager"/>

       </property>

       <property name="transactionAttributeSource">//事务的参数(隔离度,方法名等)

              <ref bean="attributeSource"/>

       </property>

</bean>

posted on 2005-03-04 14:15 jinfeng_wang 阅读(2111) 评论(1)  编辑  收藏 所属分类: spring

评论

# re: Spring Transaction 2006-11-24 14:40 Tang Anping
对JDO事务的封装,你实现了吗,我配好之后,总是报下面的异常:
org.springframework.dao.InvalidDataAccessResourceUsageException: Could not invoke JDO makePersistent(Object) method; nested exception is kodo.util.UserException: Spring Can only perform operation while a transaction is active.
kodo.util.UserException: Can only perform operation while a transaction is active.  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: