<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<!-- 数据源采用jndi方式 -->
<bean id="espDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc/bidbodbc</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="espDataSource" />
<!-- 没有引用hibernate.cfg.xml -->
<property name="mappingResources">
<list/>
</property>
<property name="hibernateProperties">
<!-- db2的dialect -->
<value>hibernate.dialect=org.hibernate.dialect.DB2Dialect</value>
</property>
</bean>
<!-- hibernate transaction manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<!-- 对所有方法事务处理 -->
<prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
</props>
</property>
</bean>
<!-- 只对以Dao结尾的bean作事务处理 -->
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="proxyTargetClass" >
<value>true</value>
</property>
<property name="beanNames">
<value>*Dao</value>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
</beans>
另外一个配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/jdbc.properties" />
</bean>
<bean id="oracleDataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>${Oraclejdbc.driverClassName}</value>
</property>
<property name="jdbcUrl">
<value>${Oraclejdbc.url}</value>
</property>
<property name="user">
<value>${Oraclejdbc.username}</value>
</property>
<property name="password">
<value>${Oraclejdbc.password}</value>
</property>
<property name="minPoolSize">
<value>1</value>
</property>
<-- 达到最大连接数后可以增加的连接数 个 -->
<property name="acquireIncrement">
<value>2</value>
</property>
<property name="maxPoolSize">
<value>3</value>
</property>
<-- 最大闲置时间 秒 -->
<property name="maxIdleTime">
<value>600</value>
</property>
<property name="maxStatements">
<value>100</value>
</property>
<-- 闲置的连接测试周期 秒 -->
<property name="idleConnectionTestPeriod">
<value>1200</value>
</property>
</bean>
<bean id="oracleSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>
com/ce/myceaas/hibernate/mis/pojo/Area.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/mis/pojo/Dept.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/mis/pojo/Users.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/mis/pojo/Employeeinfo.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/mis/pojo/AreaDept.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/mis/pojo/Roles.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/myce/pojo/Application.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/myce/pojo/Role.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/myce/pojo/User.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/myce/pojo/Userrole.hbm.xml
</value>
<value>
com/ce/myceaas/hibernate/myce/pojo/Roleprim.hbm.xml
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.generate_statistics">
${hibernate.generate_statistics}
</prop>
<prop key="hibernate.dialect">
${Oraclehibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
</props>
</property>
<property name="dataSource">
<ref local="oracleDataSource" />
</property>
</bean>
<bean id="oracleTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="oracleSessionFactory" />
</bean>
</beans>
分享到:
相关推荐
传播智客,为Spring集成的Hibernate配置二级缓存、cache.xml
NULL 博文链接:https://xiaoxuesheng.iteye.com/blog/2107997
该文档详细描述了SSH2三大主流框架的整合对于初学SSH开发的学友有一定的帮助希望大家喜欢
Spring集成hibernate3和4有一定的区别,目前基本都在使用3,所以此处内容以3为基础; 1.导入hibernate的包和Spring的包 2.创建beans.xml ... 详情查看博客:http://blog.csdn.net/omsvip
由于spring对hibernate配置文件hibernate.cfg.xml的集成相当好,可以在项目中放弃hibernate.cfg.xml文件,介绍mappingLocations、mappingDirectoryLocations与mappingJarLocations的用法和区别
1)Demo 学习要点简介: ...2.Eclipse 导入后可能需要在 Xml Catalog 手动添加:ehcache-spring-1.2.xsd(ehcache-spring-annotations-1.2.0-sources.jar里面有,自己找下)。 3.内附Oracle建表等可执行语句。
Struts2+Spring+Hibernate集成 - 基于Java开发,包含31个文件,如JAVA、XML、PROPERTIES、JSP、JS、GITIGNORE、MD、SQL和IML等。该项目为用户提供了一个基于Java的Struts2、Spring和Hibernate的集成设计,通过界面...
spring-expression-3.0.7.RELEASE.jar,spring-hibernate3.jar,spring-jms-3.0.7.RELEASE.jar,spring-tx-3.0.7.RELEASE.jar,spring-web-3.0.7.RELEASE.jar,sqljdbc4.jar,stax2-api-3.1.1.jar,velocity-1.7.jar,WHICH_...
spring+springMVC+hibernate集成,包括配置文件applicationContext.xml、web.xml、springMVC-servlet.xml
Spring: 是一个轻型的容器,利用它可以使用一个外部 XML 配置文件方便地将对象连接在一起。每个对象都可以通过显示一个 JavaBean 属性收到一个到依赖对象的引用,留给您的简单任务就只是在一个 XML 配置文件中把...
Hibernate使用方便,配置响应的XML文件即可。由于spring3.x,基于asm的某些特征,而这些asm还没有用jdk8编译,所以采用Spring 3+JDK8就会报错,提示错误信息( java.lang.IllegalArgumentException),具体解决方案有:1...
Spring_IoC集成原理的应用设计.pdf Sturts2与以其它Web应用框架整合的研究.pdf 图书缺藏网站解决方案.pdf 基于Ajax技术即时通讯系统的设计与实现.pdf 基于Ajax技术的实时数据监测系统的研究与应用.pdf 基于DWR与JST...
本系统使用Struts2.0 + Spring2.0 +Hibernate 3.2 (即:SSH)及以上版本架构整合模式开发 本系统作为学生学习SSH很有参考价值,实现了图书信息的添加,修改,删除,查询! 查询结果可以导出到excel文件! 这里是...
//applicationContext.xml文件中添加 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=...
可运行的SpringMVC项目,是通过xml配置的方式进行的,同时集成了Hibernate,数据库是Oracle,出自csdn上的linuszhu的SpringMVC经典系列。
2、 Spring配置提供了多种可选整合方案:详见applicationContext.xml的配置 (1) 提供支持三种数据源方案:C3P0、DBCP、JNDI,三选一,请注释或删除其他方案 (2) 提取四种Hibernate整合方案:四选一,请注释或...
springmvc5+hibernate5+junit4+log4j2整合实例 包含 代码实例 数据库建表sql 运行环境 myeclipes2015 jdk 1.8 tomcat 8.0
第12章:讲解了如何在Spring中集成Hibernate、myBatis等数据访问框架,同时,读者还将学习到ORM框架的混用和DAO层设计的知识。 第13章:本章重点对在Spring中如何使用Quartz进行任务调度进行了讲解,同时还涉及...
使用了SpringMVC框架,Spring4的xml配置和注解配置。 5. 前台展示页面使用了JQuery EasyUI的布局、列表和消息组件。 6. 系统实现了较为完善的用户模块,对用户数据实现了增、删、改、查、分页等的功能。
基本上,这是一个基于 maven 的 Web 项目,我在其中集成了 Spring 3.6 和 hibernate 3 以及 spring-jpa 和 jersey,在前端我曾经使用 ajax 向 REST 发送请求。 该项目演示了如何使用 Hibernate 和 Spring 框架在 ...