跨库事务处理 spring+hibernate+struts2+jta

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"> </property> <property name="url" value="jdbc:jtds:sqlserver://172.16.7.7:1433/NewsCenter"> </property> <property name="username" value="vote"></property> <property name="password" value="123456"></property> <property name="maxActive"> <value>200</value> </property> <property name="maxIdle"> <value>70</value> </property> <property name="minIdle"> <value>60</value> </property> <property name="maxWait"> <value>2000</value> </property> <property name="initialSize"> <value>60</value> </property> <property name="removeAbandoned"> <value>true</value> </property> <property name="removeAbandonedTimeout"> <value>60</value> </property> <property name="logAbandoned"> <value>true</value> </property> </bean> <bean id="newsDataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"> </property> <property name="url" value="jdbc:jtds:sqlserver://172.16.7.3:1433/NewsCenter"> </property> <property name="username" value="cahpa"></property> <property name="password" value="cahpa"></property> <property name="maxActive"> <value>200</value> </property> <property name="maxIdle"> <value>70</value> </property> <property name="minIdle"> <value>60</value> </property> <property name="maxWait"> <value>2000</value> </property> <property name="initialSize"> <value>60</value> </property> <property name="removeAbandoned"> <value>true</value> </property> <property name="removeAbandonedTimeout"> <value>60</value> </property> <property name="logAbandoned"> <value>true</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>cn/com/comment/pojos/Catalog.hbm.xml</value> <value>cn/com/comment/pojos/Manager.hbm.xml</value> <value>cn/com/comment/pojos/Role.hbm.xml</value> <!-- <value>cn/com/comment/pojos/Channels.hbm.xml</value> <value>cn/com/comment/pojos/Specials.hbm.xml</value> <value>cn/com/comment/pojos/News.hbm.xml</value> --> <value>cn/com/comment/pojos/Cmt.hbm.xml</value> <value>cn/com/comment/pojos/CmtExt.hbm.xml</value> <value>cn/com/comment/pojos/IpLock.hbm.xml</value> </list> </property> </bean> <bean id="newsSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="newsDataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <!-- <value>cn/com/comment/pojos/Catalog.hbm.xml</value> <value>cn/com/comment/pojos/Manager.hbm.xml</value> <value>cn/com/comment/pojos/Role.hbm.xml</value> <value>cn/com/comment/pojos/Cmt.hbm.xml</value> <value>cn/com/comment/pojos/CmtExt.hbm.xml</value> <value>cn/com/comment/pojos/IpLock.hbm.xml</value> --> <value>cn/com/comment/pojos/Channels.hbm.xml</value> <value>cn/com/comment/pojos/Specials.hbm.xml</value> <value>cn/com/comment/pojos/News.hbm.xml</value> </list> </property> </bean> <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" /> <bean id="myTxManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="userTransaction" ref="jotm" /> </bean> <!-- 配置事务特性--> <tx:advice id="txAdvice" transaction-manager="myTxManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <!-- 配置那些类的方法进行事务管理--> <aop:config> <aop:pointcut id="allManagerMethod" expression="execution (* cn.com.comment.service.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" /> </aop:config> <bean id="catalogDao" class="cn.com.comment.dao.catalog.impl.CatalogDAO"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="catalogService" class="cn.com.comment.service.catalog.impl.CatalogService"> <property name="catalogDao" ref="catalogDao" /> </bean> <bean id="managerDao" class="cn.com.comment.dao.manager.impl.ManagerDAO"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="managerService" class="cn.com.comment.service.manager.impl.ManagerService"> <property name="managerDao" ref="managerDao" /> </bean> <bean id="roleDao" class="cn.com.comment.dao.role.impl.RoleDAO"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="roleService" class="cn.com.comment.service.role.impl.RoleService"> <property name="roleDao" ref="roleDao" /> </bean> <bean id="channelDao" class="cn.com.comment.dao.channel.impl.ChannelDAO"> <property name="sessionFactory" ref="newsSessionFactory" /> </bean> <bean id="channelService" class="cn.com.comment.service.channel.impl.ChannelService"> <property name="channelDao" ref="channelDao" /> </bean> <bean id="specialDao" class="cn.com.comment.dao.special.impl.SpecialDAO"> <property name="sessionFactory" ref="newsSessionFactory" /> </bean> <bean id="specialService" class="cn.com.comment.service.special.impl.SpecialService"> <property name="specialDao" ref="specialDao" /> <property name="cmtDao" ref="cmtDao" /> </bean> <bean id="newsDao" class="cn.com.comment.dao.news.impl.NewsDAO"> <property name="sessionFactory" ref="newsSessionFactory" /> </bean> <bean id="newsService" class="cn.com.comment.service.news.impl.NewsService"> <property name="newsDao" ref="newsDao" /> <property name="cmtDao" ref="cmtDao" /> </bean> <bean id="cmtDao" class="cn.com.comment.dao.cmt.impl.CmtDAO"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="cmtService" class="cn.com.comment.service.cmt.impl.CmtService"> <property name="cmtDao" ref="cmtDao" /> <property name="cmtExtService" ref="cmtExtService" /> <property name="newsDao" ref="newsDao" /> <property name="specialDao" ref="specialDao" /> </bean> <bean id="cmtExtDao" class="cn.com.comment.dao.cmtext.impl.CmtExtDAO"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="cmtExtService" class="cn.com.comment.service.cmtext.impl.CmtExtService"> <property name="cmtExtDao" ref="cmtExtDao" /> </bean> <bean id="ipDao" class="cn.com.comment.dao.ip.impl.IpDAO"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="ipService" class="cn.com.comment.service.ip.impl.IpService"> <property name="ipDao" ref="ipDao" /> </bean> <!-- <import resource="modelContext.xml"/>--></beans>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值