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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
">
<!-- hibernate 交由spring 管理-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 事务类型区分 -->
<tx:advice id="transactionAvice" transaction-manager="transactionManager">
<tx:attributes>
<!--propagation="REQUIRED" 调用这些方法名开头方法产生事物-->
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<!--其它方法名开头的为只读限制,不可以更改数据库数据信息-->
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 配置产生事物的范围 com.action.*.*(..)某个包下面的所有类的所有方法的任意参数个数-->
<aop:pointcut id="transactionPointcut" expression="execution(* com.action.*.*(..)) or execution(* com.service.*.*(..)) or execution(* com.dao.*.*(..))"/>
<!-- 事物限制和连接 -->
<aop:advisor advice-ref="transactionAvice" pointcut-ref="transactionPointcut"/>
</aop:config>
</beans>
在联网的情况下tx 和 aop 标签会自动去联网 提供提示功能
在没有联网的情况下就可以通过以下配置实现标签联想功能。
1.当然首先你的要下载好spring-tx-2.0.xsd 和spring-aop-2.0.xsd文件。
然后 在wondos-->preferences-->搜索文本框中输入xml-->XML Catalog-->Add


2、

Spring和Hibernate集成配置的更多相关文章
- Spring与Hibernate集成中的Session问题
主要讨论Spring与Hibernate集成中的session问题 1.通过getSession()方法获得session进行操作 public class Test extends Hibernat ...
- Spring Boot Redis 集成配置(转)
Spring Boot Redis 集成配置 .embody{ padding:10px 10px 10px; margin:0 -20px; border-bottom:solid 1px #ede ...
- spring 整合 hibernate xml配置
spring 整合 hibernate: hibernate :对数据库交互 spring: ioc aop 整合点: 1.sessionFactory对象不再由hibernate生成,交由spr ...
- spring和hibernate集成事物管理配置方法
spring+hibernate,采用声明式事务 1.声明式事务配置 * 配置SessionFactory * 配置事务管理器 * 事务的传播特性 * 那些类那些方法使用事务 2.编写业务逻辑方法 * ...
- Spring管理 hibernate 事务配置的五种方式
Spring配置文件中关于事务配置总是由三个组成部分,DataSource.TransactionManager和代理机制这三部分,无论是那种配置方法,一般变化的只是代理机制这块! 首先我创建了两个类 ...
- 基于注解的Spring MVC整合Hibernate(所需jar包,spring和Hibernate整合配置,springMVC配置,重定向,批量删除)
1.导入jar watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400 ...
- spring与hibernate整合配置基于Annotation注解方式管理实务
1.配置数据源 数据库连接基本信息存放到properties文件中,因此先加载properties文件 <!-- jdbc连接信息 --> <context:property-pla ...
- 基于注解Spring MVC综合Hibernate(需要jar包,spring和Hibernate整合配置,springMVC组态,重定向,)批量删除
1.进口jar 2.web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app ver ...
- STS(Spring tool suite)集成配置jdk,maven和Tomcat
STS是spring官网的一个集成开发工具,最近在学springboot,所以用了. 在本文中将介绍如下内容: 搭建开发的 JDK(1.8) 环境. 配置 Maven 环境. 配置 Tomcat 环境 ...
随机推荐
- visio如何让动态连接线的单箭头变成双箭头?
1 选中线,右击,然后选择“格式”,“线条” 2 3
- javase基础笔记2——数据类型和面向对象
API:Application program interface 程序调用一个方法去实现一个功能 正则表达式:regex 用来匹配的 javaEE里边有三大框架 SSH struts spring ...
- Oracle资源
ORACLE 10g下载地址 oracle 下载还需要用户名我自己注册了个方便大家使用下载 user:1603869780@qq.compass:qwe123QWE现在直接点击不能下载了 要经过ora ...
- EventBus的使用,数据传递
通常情况下安卓下数据的传递有下面几种方法: 1.通过intent传递,包括显式意图和隐式意图,广播(Broadcast)和服务都能通过Intent传递 传递的数据类型包括8大基本数据类型 实现P ...
- android应用程序如何调用支付宝接口
最近在做一个关于购物商城的项目,项目里面付款这块我选的是调用支付宝的接口,因为用的人比较多. 在网上搜索了以下,有很多这方面的教程,但大部分教程过于陈旧,而且描述的过于简单.而且支付宝提供的接口一直在 ...
- Nginx支持多站点配置小结
如何配置 web 服务器才能在一个 VPS 上放置多个网站/博客呢?如何通过一个 IP 访问多个站点/域名呢?这是大多数 web 服务器支持的 virtual hosting 功能.即一个IP对应多个 ...
- (转)sscanf() - 从一个字符串中读进与指定格式相符的数据
(转)sscanf() - 从一个字符串中读进与指定格式相符的数据 sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: Int sscanf( string str, stri ...
- 05_Java异常(Exception)
1. 异常的概念 1.1什么是异常 异常指的是程序运行时出现的不正常情况. 1.2异常的层次 Java的异常类是处理运行时的特殊类,每一种异常对应一种特定的运行错误.所有Java异常类都是系统类库中E ...
- API
20145217 <Java程序设计>第八周学习总结 教材学习内容总结 本章主要讲输入与输出. 15.1日志API 1.java.util.logging包提供了日志功能相关类与接口,使用 ...
- iOS Cocoapods的pod install出现的某个错误 but they required a higher minimum deployment target.
关于cocoapods的安装和使用的基本教程: http://my.oschina.net/vimfung/blog/182427?fromerr=j7l3DvCG 出现以下错误提示: Specs ...