新版本中spring与hibernate整合dao层调用session的方法
来源:互联网 发布:停止mysql命令 编辑:程序博客网 时间:2024/06/14 00:13
(选自:《Beginning Hibernate》及《spring-framework-3.0.5.RELEASE reference》)
在spring和hibernate整合框架中,session factory被配置为一个spring bean,以前版本会利用HibernateDaoSupport和HibernateTemplate这两个类,在新版本中可直接利用方法session factory的getCurrentSession()返回当前事务的session。
如:
Session
per transaction. This is roughly equivalent to Spring's synchronization of one Hibernate Session
per transaction. A corresponding DAO implementation resembles the following example, based on the plain Hibernate API:)SessionFactory.getCurrentSession() 方法, 返回当前spring管理的事务session,
SessionFactory.getCurrentSession() method for any Spring transaction strategy, returning
the current Spring-managed transactional Session even with HibernateTransactionManager.)
With your session factory configured as a Spring bean, you can now go on to create DAOs that take
advantage of Hibernate’s functionality. Previous versions of Spring and Hibernate required the use of
the HibernateDaoSupport class and/or HibernateTemplate class to form the basis of your DAOs; however,
recent versions of Spring and Hibernate have eliminated the need for these classes. Hibernate now
supports a getCurrentSession() method on the SessionFactory that returns a Session object that is
associated with the current transaction.
- 新版本中spring与hibernate整合dao层调用session的方法
- SSH整合(spingmvc,spring,hibernate)以及Dao层抽取方法
- Spring+Hibernate整合框架下DAO的数据库访问方法
- Hibernate DAO层调用存储过程方法
- 求解——spring+Hibernate中Dao内的方法执行到Session session=getSession();后停止运行
- 第二次报错:在spring+springMVC+hibernate中,controller调用service层方法或者dao层方法,报错java.lang.NullPointerException
- 虚拟数据层 Struts2、Hibernate、Spring整合的泛型DAO Version 2010.9.27
- 虚拟数据层:Struts2、Hibernate、Spring整合的泛型DAO
- spring项目在main方法中调用持久层service或dao层
- 基于Spring、Hibernate的通用DAO层与Service层的实现
- 基于Spring、Hibernate的通用DAO层与Service层的实现
- 基于Spring、Hibernate的通用DAO层与Service层的实现
- 基于Spring、Hibernate的通用DAO层与Service层的实现
- 基于Spring、Hibernate的通用DAO层与Service层的实现
- Spring中获得Hibernate Session的方法
- Spring与Hibernate Dao中操作数据库的另外方式
- hibernate的dao层
- JUNIT测试Hibernate和Spring的Dao层方法出现的问题
- asp.net 在 DCOM编程时需要配置的
- android NinePatchDrawable 9.png图片使用制作
- 禄来6008机身和镜头之间的通信协议测试
- jquery和js操作checkbox radio select
- #Pragma用法
- 新版本中spring与hibernate整合dao层调用session的方法
- BW:SID冲突:问题描述及处理 By Greed_zy
- 如何成功卸载WebSphere Portal V6.0
- linux shell脚本简单示例
- setup a subversion server
- Address already in use: 8080【错误】
- Udev 内核机制(kobject_uevent) 性能优化
- Linux设备驱动程序学习(12) -Linux设备模型(底层原理简介)
- 小结主要排序算法