<?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集成配置的更多相关文章

  1. Spring与Hibernate集成中的Session问题

    主要讨论Spring与Hibernate集成中的session问题 1.通过getSession()方法获得session进行操作 public class Test extends Hibernat ...

  2. Spring Boot Redis 集成配置(转)

    Spring Boot Redis 集成配置 .embody{ padding:10px 10px 10px; margin:0 -20px; border-bottom:solid 1px #ede ...

  3. spring 整合 hibernate xml配置

    spring 整合 hibernate: hibernate :对数据库交互 spring: ioc   aop 整合点: 1.sessionFactory对象不再由hibernate生成,交由spr ...

  4. spring和hibernate集成事物管理配置方法

    spring+hibernate,采用声明式事务 1.声明式事务配置 * 配置SessionFactory * 配置事务管理器 * 事务的传播特性 * 那些类那些方法使用事务 2.编写业务逻辑方法 * ...

  5. Spring管理 hibernate 事务配置的五种方式

    Spring配置文件中关于事务配置总是由三个组成部分,DataSource.TransactionManager和代理机制这三部分,无论是那种配置方法,一般变化的只是代理机制这块! 首先我创建了两个类 ...

  6. 基于注解的Spring MVC整合Hibernate(所需jar包,spring和Hibernate整合配置,springMVC配置,重定向,批量删除)

    1.导入jar watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400 ...

  7. spring与hibernate整合配置基于Annotation注解方式管理实务

    1.配置数据源 数据库连接基本信息存放到properties文件中,因此先加载properties文件 <!-- jdbc连接信息 --> <context:property-pla ...

  8. 基于注解Spring MVC综合Hibernate(需要jar包,spring和Hibernate整合配置,springMVC组态,重定向,)批量删除

    1.进口jar 2.web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app ver ...

  9. STS(Spring tool suite)集成配置jdk,maven和Tomcat

    STS是spring官网的一个集成开发工具,最近在学springboot,所以用了. 在本文中将介绍如下内容: 搭建开发的 JDK(1.8) 环境. 配置 Maven 环境. 配置 Tomcat 环境 ...

随机推荐

  1. 对于Eclipse的正确用法

    有时候我们刚刚修改了工程里的文件 但是启动的时候它硬是说你有东西没有声明 而那个东西又明明在那里.. 这时候我们可以认为实际与它调用的工程关系文件(我假想的) 不同步.. 我们可以通过clean功能来 ...

  2. java.util.List接口的方法subList()的使用注意事项

    JDK中,List接口有一个实例方法List<E> subList(int fromIndex, int toIndex), 其作用是返回一个以fromIndex为起始索引(包含),以to ...

  3. XSS 跨站脚本攻击之ShellCode的调用

    1.ShellCode,最初是溢出程序和蠕虫病毒的核心,实际上是指利用一个漏洞是所执行的代码,在XSS跨站脚本中,是指由javascript等脚本编写的XSS利用代码: 2.Exploit,在黑客眼里 ...

  4. css整理-03 文本

    缩进和水平对齐 缩进文本:text-indent 可以设置为负值 可以为所有块级元素应用,但无法应用到行内元素,图像之类的替换元素: 水平对齐: text-align left,center,righ ...

  5. Swift3.0语言教程查找字符集和子字符串

    Swift3.0语言教程查找字符集和子字符串 Swift3.0语言教程查找字符集和子字符串,在字符串中当字符内容很多时,我们就需要使用到查找字符集或者子字符串的方法.以下我们将讲解3种查找字符集和子字 ...

  6. zepto的bug1

    给页面<a>标签绑定了tap事件,在移动设备上点击按钮貌似一切正常,可以正常响应. 但是,把页面上下滑动几次之后,或者在滑动时手指滑动出移动屏幕之外,之后再点击按钮,就会发现第一次点击的时 ...

  7. CSS3设置多张背景图片

    background-image:url("1.jpg"),url("2.jpg"),url("3.jpg");background-rep ...

  8. java.net.SocketException: No buffer space available

    https 访问url在调用量不大的情况下 java.net.SocketException: No buffer space available (maximum connections reach ...

  9. 转 Delphi中使用FastMM4结合View CPU避免内存泄漏

    http://www.cnblogs.com/kongchao/archive/2009/10/27/1590479.html 核心提示:内存泄漏经常出现在本地代码中,特别是多线程和发生异常的情况下, ...

  10. PHP Java 设置cookie方法

      Java Cookie cookie = new Cookie(COOKIE_NAME, encrypt_cookieV); cookie.setMaxAge(60 * 60); cookie.s ...