<? 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: context = "http://www.springframework.org/schema/context"
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.5.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context-2.5.xsd
Http://www.springframework.org/schema/aop
Http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
Http://www.springframework.org/schema/tx
Http://www.springframework.org/schema/tx/spring-tx-2.5.xsd>
<! -- Annotation transaction-driven -->
<TX: annotation-driven transaction-Manager = "transactionmanager" proxy-target-class = "true"/>
<! --
JTA is a Java Interface Specification for standardized Distributed Transaction access proposed by Sun.
Manually encode JTA
Context context = new initialcontext ();
Usertransaction ut = (usertransaction) Context. Lookup ("javax. transaction. usertransaction ")
Ut. Commit ();
Ut. rollback ();
Java transaction API (JTA) is an advanced API independent of implementation and protocol. It enables applications and application servers to access transactions.
The JTA Specification defines only a set of Java interface definitions. The specific implementation is left to the corresponding provider for implementation. Each Java EE application server must provide support for JTA.
In addition to the JTA implementation that can be bound to various Java EE application servers, there are also several independent and mature JTA implementation products on the Java platform:
1. JTA 2, atomikos 3, JBoss transactions
Tomcat does not support JTA, so cross-Database Transaction Management is implemented using spring.
Jotm (Java open Transaction Manager) is a full-featured, open-source Independent Transaction Manager developed by the objectweb organization and fully compatible with JTA (Java transaction API)
-->
<Bean id = "jotm" class = "org. springframework. transaction. JTA. jotmfactorybean"> </bean>
<! -- JTA Transaction Manager -->
<Bean id = "transactionmanager" class = "org. springframework. transaction. JTA. jtatransactionmanager">
<! -- Specify the usertransaction attribute to reference the local jotm instance -->
<Property name = "usertransaction" ref = "jotm"/>
</Bean>
<! -- Corresponds to the xapool configuration of MySQL database construct_bank, which contains an Xa data source -->
<Bean id = "constructds" class = "org. enhydra. JDBC. Pool. standardxapooldatasource">
<Property name = "datasource">
<! -- Configure the MySQL database for the internal XA data source -->
<Bean class = "org. enhydra. JDBC. Standard. standardxadatasource">
<Property name = "transactionmanager" ref = "jotm"/>
<Property name = "drivername" value = "com. MySQL. JDBC. Driver"/>
<Property name = "url" value = "JDBC: mysql: // 127.0.0.1: 3306/construct_bank"/>
</Bean>
</Property>
<Property name = "user" value = "root"/>
<Property name = "password" value = "root"/>
</Bean>
<Bean id = "sessionfactory_constructbank" class = "org. springframework. hibernate3.localsessionfactorybean">
<Property name = "datasource">
<Ref bean = "constructds"/>
</Property>
<Property name = "hibernateproperties">
<Props>
<Prop key = "hibernate. dialect"> org. hibernate. dialect. mysqldialect </prop>
<Prop key = "hibernate. hbm2ddl. Auto"> Update </prop>
<Prop key = "hibernate. show_ SQL"> true </prop>
<Prop key = "hibernate. format_ SQL> true </prop>
</Props>
</Property>
<Property name = "mappingresources">
<List>
<Value> ORG/oneedu/pojo/user. HBM. xml </value>
<Value> ORG/oneedu/pojo/card. HBM. xml </value>
</List>
</Property>
</Bean>
<Bean id = "businessds" class = "org. enhydra. JDBC. Pool. standardxapooldatasource">
<Property name = "datasource">
<! -- Internal XA data source configuration Mysql Data source -->
<Bean class = "org. enhydra. JDBC. Standard. standardxadatasource">
<Property name = "transactionmanager" ref = "jotm"/>
<Property name = "drivername" value = "com. MySQL. JDBC. Driver"/>
<Property name = "url" value = "JDBC: mysql: // 127.0.0.1: 3306/business_bank"/>
</Bean>
</Property>
<Property name = "user" value = "root"/>
<Property name = "password" value = "root"/>
</Bean>
<Bean id = "sessionfactory_businateank" class = "org. springframework. Orm. hibernate3.localsessionfactorybean">
<Property name = "datasource">
<Ref bean = "businessds">
</Property>
<Property name = "hibernateproperties">
<Props>
<Prop key = "hibernate. dialect"> org. hibernate. dialect. mysqldialect </prop>
<Prop key = "hibernate. hbm2ddl. Auto"> Update </prop>
<Prop key = "hibernate. show_ SQL"> true </prop>
<Prop key = "hibernate. format_ SQL"> true </prop>
<Props>
</Property>
<Property name = "mappingresources">
<List>
<Value> ORG/oneedu/pojo/user2.hbm. xml </value>
<Value> ORG/oneedu/pojo/card2.hbm. xml </value>
</List>
</Property>
</Bean>
<Bean id = "hibernatetemplate_constructbank" class = "org. springframework. Orm. hibernate3.hibernatetemplate">
<Property name = "sessionfactory">
<Ref local = "sessionfactory_constructbank"/>
</Property>
</Bean>
<Bean id = "hibernatetemplate_constructbank" class = "org. springframework. Orm. hibernate3.hibernatetemplate">
<Property name = "sessionfactory">
<Ref local = "sessionfactory_businessbank"/>
</Property>
</Bean>
</Beans>