<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd"><bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource" ref="dataSource"></property><property name="packagesToScan" value="com.entity"></property><property name="hibernateProperties"><props> <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop><prop key="show_sql">true</prop><prop key="hibernate.cache.use_query_cache">true</prop><prop key="hibernate.cache.use_second_level_cache">true</prop><prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop></props></property></bean><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><property name="sessionFactory" ref="sessionFactory"></property></bean><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property><property name="url" value="jdbc:oracle:thin:@192.168.73.7:1521:orcl"></property><property name="username" value="scott"></property><property name="password" value="orcl"></property></bean><!-- 声明式事务配置 -->   <bean id="transactionManager"  class="org.springframework.orm.hibernate3.HibernateTransactionManager">  <property name="sessionFactory" ref="sessionFactory" />  </bean>  <tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="find*" read-only="true" propagation="SUPPORTS" rollback-for="Exception"/><tx:method name="get*" read-only="true" propagation="SUPPORTS" rollback-for="Exception"/><tx:method name="add*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="remove*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="modi*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="alter*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="edit*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/><tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/> </tx:attributes></tx:advice><!-- 启用事务 --><aop:config><aop:pointcut id="bussinessService"expression="execution(* com.service.*.*(..))" /><aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" /><!--方法权限控制 --><!-- <aop:aspect ref="methodFilter"> --><!-- <aop:around pointcut-ref="bussinessService" method="doMethodBefore" /> --><!-- </aop:aspect> --></aop:config><context:annotation-config />     <!-- 使用annotation定义事务-->  <context:component-scan base-package="com.*" ><!-- <context:exclude-filter type="annotation"expression="org.springframework.stereotype.Repository" /> --><!--          <context:exclude-filter type="assignable" -->
<!--            expression="imooc_spring.test.anotation.TestObj" /> --></context:component-scan>
</beans>

转载于:https://www.cnblogs.com/skategenji/p/7250746.html

spring + hibernate + 实体类 注解配置代码相关推荐

  1. hibernate实体类注解

    <!-- 基于annotation的配置 --> <mapping class="com.xiaoluo.bean.User"/> <!-- 基于hb ...

  2. Hibernate注解开发-PO类注解配置

    在hibernate中我们使用注解,可以帮助我们简化hbm文件配置. hibernate.cfg.xml配置 <?xml version="1.0" encoding=&qu ...

  3. Spring Boot 实体类 Entity的自动生成,利用Python实现 sql 语句快速转换成 Java 代码(一)

    引言 最近,自己开始学习Java后端开发,作为小白,在导师的指导下,一步步开始学习,从如何搭建springboot项目开始,连接上 MySQL 数据库之后,再创建和编写Entity.Controlle ...

  4. SpringBoot24 SpringDataJPA环境搭建、实体类注解、关联查询

    1 版本说明 JDK:1.8 MAVEN:3.5 SpringBoot:2.0.4 IDEA:旗舰版207.2 MySQL:5.5 2 SpringDataJPA环境搭建(SpringBoot版本) ...

  5. eclipse从数据库逆向生成Hibernate实体类

    2019独角兽企业重金招聘Python工程师标准>>> 做项目必然要先进行数据库表设计,然后根据数据库设计建立实体类(VO),这是理所当然的,但是到公司里做项目后,让我认识到,没有说 ...

  6. Spring+Hibernate+c3p0连接池配置-连接无法释放的问题解决方案

     1.Spring+Hibernate+c3p0连接池配置: <?xml version="1.0" encoding="UTF-8"?> < ...

  7. spring MVC请求处理类注解属性详解

    spring MVC请求处理类注解属性详解

  8. Spring中实体类为什么不需要注册成bean?

    今天偶然想到一个问题,Spring中实体类为什么不需要注册成bean? 要理解为什么不用注入,首先就清楚注入的目的是什么?如果不注入,在程序中要使用某个类对象的方法,则需要去new一个对象.然后我们调 ...

  9. Spring boot实体类中常用基本注解

    1.@TableField exist 表示是否为是数据库字段 select 表示是否查询该字段 value表示表中字段名和实体类的字段名不一致时,value=表中字段名 (1)@TableField ...

最新文章

  1. 厉害!这位北科大博士生,4年9篇SCI一作
  2. 微软称电脑系统识别能力已经超越了人类
  3. 学习spring过程看的笔记(一)
  4. 1.7 Java字符流的使用:字符输入/输出流、字符文件和字符缓冲区的输入/输出流
  5. 看电影也花屏,谁是幕后元凶
  6. python层次聚类法画图_Python实现简单层次聚类算法以及可视化
  7. 已知先序和中序得出后序
  8. android 使用注解
  9. a标签download属性无效_使用这些 CSS 属性选择器来提高前端开发效率
  10. mysql 跳过授权表_跳过授权表登录后使用replace into创建root权限用户
  11. 今天中午还收到了,一条诈骗短信,说是中奖了
  12. QT表格QTableWidget在win10下纵横表头无分隔线的问题
  13. Tarjan算法详解
  14. IDEA上传代码至github
  15. 关于核磁共振图像的命名原则及含义(总结自用)
  16. python scripting for arcgis_Python Scripting for ArcGIS Pro
  17. node-sassnpm ERR! command failed
  18. 怎么让span与img在同一行
  19. 持续集成(三)- hudson插件入门
  20. 基于Java实现的中文分词系统

热门文章

  1. hihoCoder1690 (动态规划)
  2. 用户空间与内核空间,进程上下文与中断上下文[总结]【转】
  3. python3 读取写入excel操作-win32com
  4. iOS.ReactNative-3-about-viewmanager-uimanager-and-bridgemodule
  5. eclipse中添加插件的方法
  6. 跨网段加域的一个问题
  7. Js中Currying的应用
  8. 电平通讯速度_飞凌干货丨几种常见的电平转换电路分析及应用
  9. 如何使用Emacs Org模式和Reveal.js创建幻灯片
  10. 测试beta测试_重新想象不断变化的自动化世界中的Beta测试