HibernateTemplate与SessionFactory [英] HibernateTemplate vs SessionFactory

查看:81
本文介绍了HibernateTemplate与SessionFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许有人可以解释使用哪一个?何时以及为什么?

HibernateTemplate的javadoc 说:


注意:从Hibernate 3.0.1开始,事务性Hibernate访问代码
也可以用简单的Hibernate风格编码。因此,对于新开始的
项目,考虑采用标准的Hibernate3风格的编码
数据访问对象,而不是基于
SessionFactory.getCurrentSession()。


< blockquote>

所以即使Spring告诉你不要再使用Spring的HibernateTemplate了。 Hibernate4没有HibernateTemplate。选择应该很明显。


Maybe someone could explain which one to use? When and why?

解决方案

The javadoc of HibernateTemplate says:

NOTE: As of Hibernate 3.0.1, transactional Hibernate access code can also be coded in plain Hibernate style. Hence, for newly started projects, consider adopting the standard Hibernate3 style of coding data access objects instead, based on SessionFactory.getCurrentSession().

So even Spring tells you not to use Spring's HibernateTemplate anymore. And there is no HibernateTemplate for Hibernate4. The choice should be obvious.

这篇关于HibernateTemplate与SessionFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆