hibernate的beans.xml配置
来源:互联网 发布:淘宝主播刷人气 编辑:程序博客网 时间:2024/06/05 22:38
hibernate使用c3p0连接池配置:
头:<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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
1.创建数据源(c3p0)
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close">
<property name="driverClass" value="数据库驱动包(oracle.jdbc.driver.OracleDriver)“ />
<property name="jdbcUrl" value="jdbc的URL(jdbc:oracle:thin:@127.0.0.1:1521:orcl)" />
<property name="user" value="用户名(klm)" />
<property name="password" value="用户密码(klm123)" />
</bean>
2.开启注解:
<context:annotation-config/>
3.设置扫描包
<context:component-scan base-package="扫描的包名(com.card.memberSystem)"/>
4.使用注解配置AspectJ,先注册aspectj
<aop:aspectj-autoproxy/>
5.使用注解配置事物 ,tx的transaction-manager属性默认值就是"transactionManager"
<tx:annotation-driven transaction-manager="txManager"/>
6.配置sessionfactory
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
p:dataSource-ref="dataSource" p:configLocations="classpath:hibernate配置的文件名(hibernate.cfg.xml)"/>
7.实例化事务管理器
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
8.配置事务的传播特性 ,指定事务管理器
<tx:advice id="txAdvice" transaction-manager="txManager">
9.配置详细的事务语义
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="find*" read-only="true" propagation="REQUIRED" />
<tx:method name="*" read-only="false" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
10.配置切面
<aop:config>
<aop:pointcut id="pc" expression="execution(* 要配置的包名.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/>
</aop:config>
eg:
<aop:config>
<aop:pointcut id="pc" expression="execution(* com.card.memberSystem.business.systemSet.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/>
</aop:config>
- hibernate的beans.xml配置
- eclipse luna4.4配置beans.xml和hibernate.cfg.xml提示类的包路径信息
- eclipse luna4.4配置beans.xml和hibernate.cfg.xml提示类的包路径信息
- jsf、Spring、Hibernate 集成 faces-managed-beans.xml 配置
- beans.xml配置
- 运用jpa技术的beans.xml文件配置
- 4.1 Spring beans的创建和配置(XML方式)
- Spring beans.xml(applicationContext.xml) 配置
- beans.xml 和 applicationContext.xml配置区别
- beans的配置
- Hibernate.cfg.xml的配置
- Hibernate.cfg.xml的配置
- Hibernate hbm.xml的配置
- hibernate 的hbm.xml配置
- Hibernate基于xml的配置
- hibernate.cfg.xml的配置
- hibernate.cfg.xml的配置
- hibernate 的hbm.xml配置
- child process failed, exited with error number 100
- CEF3研究(一)
- 六、打哪指哪
- Start Developing iOS Apps (Swift) 学习笔记 (2)
- 浅谈HTTP中Get与Post的区别
- hibernate的beans.xml配置
- CEF研究(二)
- gunicorn部署django实例
- 最新版SDWebImage的使用
- Cannot find or open the PDB file问题的解决
- 笔记本外接显示器“水波纹”闪烁
- Errors running builder 'DeploymentBuilder' on project '工程名'
- MAC系统下如何打开 gif图片
- jquery 中的html()获取的特殊字符被浏览器转义