Transaction management strategies

xml 代码
  1. <beans>  
  2.   
  3.   <bean id="myDataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">  
  4.     <property name="jndiName value="java:comp/env/jdbc/myds1"/>  
  5.   </bean>  
  6.   
  7.   <bean id="myDataSource2" class="org.springframework.jndi.JndiObjectFactoryBean">  
  8.     <property name="jndiName" value="java:comp/env/jdbc/myds2"/>  
  9.   </bean>  
  10.   
  11.   <bean id="mySessionFactory1" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">  
  12.     <property name="dataSource" ref="myDataSource1"/>  
  13.     <property name="mappingResources">  
  14.       <list>  
  15.         <value>product.hbm.xml</value>  
  16.       </list>  
  17.     </property>  
  18.     <property name="hibernateProperties">  
  19.       <props>  
  20.         <prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>  
  21.       </props>  
  22.     </property>  
  23.   </bean>  
  24.   
  25.   <bean id="mySessionFactory2" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">  
  26.     <property name="dataSource" ref="myDataSource2"/>  
  27.     <property name="mappingResources">  
  28.       <list>  
  29.         <value>inventory.hbm.xml</value>  
  30.       </list>  
  31.     </property>  
  32.     <property name="hibernateProperties">  
  33.       <props>  
  34.         <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>  
  35.       </props>  
  36.     </property>  
  37.   </bean>  
  38.   
  39.   <bean id="myTxManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>  
  40.   
  41.   <bean id="myProductDao" class="product.ProductDaoImpl">  
  42.     <property name="sessionFactory" ref="mySessionFactory1"/>  
  43.   </bean>  
  44.   
  45.   <bean id="myInventoryDao" class="product.InventoryDaoImpl">  
  46.     <property name="sessionFactory" ref="mySessionFactory2"/>  
  47.   </bean>  
  48.   
  49.   <bean id="myProductServiceTarget" class="product.ProductServiceImpl">  
  50.     <property name="productDao" ref="myProductDao"/>  
  51.     <property name="inventoryDao" ref="myInventoryDao"/>  
  52.   </bean>  
  53.   
  54.   <bean id="myProductService"  
  55.         class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
  56.     <property name="transactionManager" ref="myTxManager"/>  
  57.     <property name="target" ref="myProductServiceTarget"/>  
  58.     <property name="transactionAttributes">  
  59.       <props>  
  60.         <prop key="increasePrice*">PROPAGATION_REQUIRED</prop>  
  61.         <prop key="someOtherBusinessMethod">PROPAGATION_REQUIRES_NEW</prop>  
  62.         <prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>  
  63.       </props>  
  64.     </property>  
  65.   </bean>  
  66.   
  67. </beans>  

你可能感兴趣的:(Hibernate,xml,bean,orm,jdbc)