spring 与 hibernate 及事务的配置
2008-10-29 12:55
393 查看
spring 与hibernate 及事务的配置:
<?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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- Hibernate SessionFactory -->
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="mysqldataSource1" />
</property>
<!--
<property name="mappingResources">
<list>
<value>com/xh/hibernate/entity/User.hbm.xml</value>
</list>
</property
-->
<property name="mappingLocations">
<list>
<!--value>classpath:/com/company/club/**/*.hbm.xml</value-->
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.connection.release_mode">auto</prop>
<prop key="hibernate.autoReconnect">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="hibernateSessionFactory" />
</property>
</bean>
<bean id="abstractTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<!-- prop key="set*">PROPAGATION_REQUIRED,timeout_80</prop-->
<prop key="save*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="create*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="update*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="delete*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!--
把事务配置在service层
<bean id="daoTarget" class="a dao class impl " lazy-init="true">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="daoService" parent="abstractTransactionProxy">
<property name="target" ref="daoTarget"/>
</bean>
-->
</beans>
<?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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- Hibernate SessionFactory -->
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="mysqldataSource1" />
</property>
<!--
<property name="mappingResources">
<list>
<value>com/xh/hibernate/entity/User.hbm.xml</value>
</list>
</property
-->
<property name="mappingLocations">
<list>
<!--value>classpath:/com/company/club/**/*.hbm.xml</value-->
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.connection.release_mode">auto</prop>
<prop key="hibernate.autoReconnect">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="hibernateSessionFactory" />
</property>
</bean>
<bean id="abstractTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<!-- prop key="set*">PROPAGATION_REQUIRED,timeout_80</prop-->
<prop key="save*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="create*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="update*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="delete*">PROPAGATION_REQUIRED,timeout_80</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!--
把事务配置在service层
<bean id="daoTarget" class="a dao class impl " lazy-init="true">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="daoService" parent="abstractTransactionProxy">
<property name="target" ref="daoTarget"/>
</bean>
-->
</beans>
相关文章推荐
- spring mvc+hibernate 实现事务管理(配置文件版)
- Spring中如何配置Hibernate事务
- Spring整合Hibernate开发 - 使用事务管理器操作数据库 - 主配置文件
- spring+hibernate xml和注解方式配置事务
- Spring3.x_Struts2.x_Hibernate3.x整合之声明式事务配置
- spring mvc+hibernate 实现事务管理(配置文件版)
- Spring中如何配置Hibernate事务
- spring2.5 struts2 hibernate3 时事务配置注意的问题 openSessionInViewFilter web.xml
- Spring整合Hibernate时,配置事务处理
- spring 配置hibernate事务处理
- Spring管理 hibernate 事务配置的五种方式
- spring 4 + hibernate 4 配置数据库事务
- Spring的四种声明式事务的配置-Hibernate事务
- Spring中如何配置Hibernate事务
- Spring管理 hibernate 事务配置的五种方式
- spring 同时配置hibernate and jdbc 事务
- spring 同时配置hibernate and jdbc 事务
- Spring配置Hibernate的事务的五种方式
- maven 项目(三)引申--spring集成hibernate+JPA事务配置(扫描注解)
- Spring管理 hibernate 事务配置的五种方式