`
zjnbshifox
  • 浏览: 312566 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

Spring MVC3 Hibernate3 Annotation 补充

    博客分类:
  • Java
阅读更多
通过配置文件进行事务声明
app-config.xml
<?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:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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">

	<bean id="dataSource"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>
				jdbc:mysql://localhost/blog?useUnicode=true&amp;characterEncoding=utf-8
			</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value></value>
		</property>
	</bean>

	<!-- Hibernate SessionFactory -->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource">
			<ref local="dataSource" />
		</property>
		<property name="packagesToScan" value="gov.rsj.calendar.model" />
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager" 	class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref local="sessionFactory" />
		</property>
	</bean>

	<aop:config>
		<aop:pointcut id="serviceOperation" expression="execution(* gov.rsj.*.service..*Service.*(..))" />
		<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
	</aop:config>


	<tx:advice id="txAdvice">
		<tx:attributes>
			<tx:method name="del*" propagation="REQUIRED" />
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="create*" propagation="REQUIRED" />
			<tx:method name="get*" read-only="true" />
			<tx:method name="*" />
		</tx:attributes>
	</tx:advice>

	<!-- tx:annotation 自动配置事务,注意这个标签必需放在tx:advice下面,否则不起作用 -->
	<tx:annotation-driven />
	
	<context:component-scan base-package="gov.rsj">    
       <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>   
    </context:component-scan> 
</beans>

分享到:
评论

相关推荐

    Spring MVC + Hibernate +Annotation

    Spring MVC 整合Hibernate的一个小小的用例,适合初学Spring MVC 的学者。

    Spring4 MVC Hibernate4集成(Annotation)

    Spring4 MVC Hibernate4集成,使用Annotation,封装dao层和service层。 环境: spring 4.0.3.RELEASE hibernate 4.3.5.Final mysql 5.1.29

    Spring_Hibernate_JAVAX_Annotation注解

    SSH开发注解大全,涉及到的注解内容涵盖AspectJ,Batch,Spring,Cache,Data-Jpa,Integration,JMX,Roo,Security,Test,MVC,WS,JSR(168,222,224,250,299,303,314,317,330,220),Hibernate 3

    SpringMVC+Hibernate+annotation+Easyui权限管理系统

    SpringMVC+Hibernate+annotation+Easyui权限管理系统,Session过期控制(包括Ajax请求的过期控制),访问权限控制(权限控制到按钮),hibernate数据库用户名与密码加密,其它的不说了,绝对物有所值

    springmvc + hibernate annotation 配置

    springmvc + hibernate annotation 配置

    springMVC + spring + hibernate 整合的管理系统小案例

    下载后请修改数据库用户名和密码,即springAnnotation-hibernate.xml文件 案例系统支持功能如下: 注册功能,身份证,邮箱,手机号,姓名等校验,ajax异步获取资源 分页显示,编辑更新,多行删除等更功能,使用了MVC...

    Spring MVC事务配置

    一、      XML,使用tx标签配置拦截器实现事务 一、      Annotation方式 以下所使用环境为Spring4.0.3、Hibernate4.3.5

    spring_MVC源码

    18. class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; 19. &lt;property name="dataSource" ref="dataSource" /&gt; 20. &lt;property name="hibernateProperties"&gt; 21. &lt;props&gt; 22...

    struts2+hibernate3+spring整合

    此项目是struts2 + hibernate3(annotation) + spring(annotation)整合后的项目雏形,基于MVC的设计思想,很适合初学ssh框架的童鞋参考

    Spring.3.x企业应用开发实战(完整版).part2

    Spring3.0是Spring在积蓄了3年之久后,隆重推出的一个重大升级版本,进一步加强了Spring作为Java领域第一开源平台的翘楚地位。  Spring3.0引入了众多Java开发者翘首以盼的新功能和新特性,如OXM、校验及格式化框架...

    SpringMVC+Hibernate全注解整合

    &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;value&gt;com.org.entity&lt;/value&gt; &lt;prop key="hibernate....

    Getting.started.with.Spring.Framework.2nd.Edition1491011912.epub

    Chapter 6- Annotation-driven development with Spring Chapter 7 - Database interaction using Spring Chapter 8 - Messaging, emailing, asynchronous method execution, and caching using Spring Chapter 9 - ...

    Spring3.x企业应用开发实战(完整版) part1

    Spring3.0是Spring在积蓄了3年之久后,隆重推出的一个重大升级版本,进一步加强了Spring作为Java领域第一开源平台的翘楚地位。  Spring3.0引入了众多Java开发者翘首以盼的新功能和新特性,如OXM、校验及格式化框架...

    JSR303依赖的jar包

    Spring MVC 3.x 之中也大力支持 JSR-303,可以在控制器中对表单提交的数据方便地验证。 该压缩包包含了hibernate-validator-5.2.4.Final.jar、hibernate-validator-annotation-processor-5.2.4.Final.jar、...

    spring-boot-reference.pdf

    Auto-configured Spring REST Docs Tests with Mock MVC Auto-configured Spring REST Docs Tests with REST Assured 43.3.20. User Configuration and Slicing 43.3.21. Using Spock to Test Spring Boot ...

    springMVC数据校验.zip

    SpringMVC JSR 数据校验完整jar包下载,一共六个jar包,classmate-1.0.0.jar,hibernate-validator-5.0.0.final.jar,hibernate-validator-annotation-processor-5.0.1.final.jar,hibernate-validator-cdi-5.0.0....

    Spring中文帮助文档

    2.5.1. Spring MVC合理的默认值 2.5.2. Portlet 框架 2.5.3. 基于Annotation的控制器 2.5.4. Spring MVC的表单标签库 2.5.5. 对Tiles 2 支持 2.5.6. 对JSF 1.2支持 2.5.7. JAX-WS支持 2.6. 其他 2.6.1. 动态...

    Spring API

    2.5.1. Spring MVC合理的默认值 2.5.2. Portlet 框架 2.5.3. 基于Annotation的控制器 2.5.4. Spring MVC的表单标签库 2.5.5. 对Tiles 2 支持 2.5.6. 对JSF 1.2支持 2.5.7. JAX-WS支持 2.6. 其他 2.6.1. 动态...

    Aspectj in Action: Enterprise AOP with Spring Applications (2nd Edition)

    Building on familiar technologies such as JDBC, Hibernate, JPA, Spring Security, Spring MVC, and Swing, you'll apply AOP to common problems encountered in enterprise applications. This book requires...

Global site tag (gtag.js) - Google Analytics