Spring 中基础配置和事务管理的配置和spring托管hibernate配置文件的方法
2009-01-14 13:37
826 查看
]Spring 中基础配置和事务管理的配置和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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" > <!-- sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> //在src文件夹下 </property> </bean> <!-- transactionManager --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <!-- DAO --> <bean id="userDAO" class="com.dao.impl.UserDAO"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <!-- service Proxy --> <bean id="proxyService" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="transactionManager"/> </property> <property name="proxyTargetClass" value="true" /> <property name="transactionAttributes"> <props> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="is*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <!-- Service --> <bean id="service" class="com.service.impl.Service"> <property name="userDAO"> <ref bean="userDAO" /> </property> </bean> <!--Proxy Service --> <bean id="serviceProxy" parent="proxyService"> <property name="target"> <ref bean="service" /> </property> </bean> <!-- Struts2 Action --> <bean id="userAction" class="com.action.UserAction" scope="prototype">//prototype是在一个 Action中有多个提交请求 <property name="service"> <ref bean="serviceProxy"/> </property> </bean>
相关文章推荐
- spring hibernate整合时配置文件的事务部分(spring管理事务)
- Spring整合Hibernate开发 - 使用事务管理器操作数据库 - 主配置文件
- spring 管理事务配置时,结果 报错: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here这个异常
- Spring3.0配置多个事务管理器(即操作多个数据源)的方法
- Spring学习笔记(16)----使用Spring配置文件实现事务管理
- Spring管理 hibernate 事务配置的五种方式
- Spring管理 hibernate 事务配置的五种方式
- spring和hibernate集成事物管理配置方法
- spring管理hibernate事务报异常--Transaction not successfully started解决方法
- Xml配置实现Spring_Hibernate中的声明式事务管理
- spring+hibernate 两种整合方式配置文件的方法
- spring管理hibernate的SessionFactory-多种配置方法
- (转)使用Spring配置文件实现事务管理
- 关于spring4和hibernate4整合,配置事务报“Cannot unwrap to requested type [javax.sql.DataSource]”错误的解决方法及心得
- Spring中使用事务搭建转账环境方法二 相对简便的注解方法 ——配置文件注入对象属性需要setter方法 注解方法,不需要生成setter方法
- Spring -- spring结合aop 进行 tx&aspectj事务管理配置方法
- Spring与Hibernate的整合,不配置事务管理器,事务会自动提交(Hibernate默认手动提交)
- spring管理事务的配置文件
- spring 管理N多个hibernate文件 的简便方法
- Spring管理 hibernate 事务配置的五种方式