HibernateTemplate与SessionFactory [英] HibernateTemplate vs SessionFactory
问题描述
注意:从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屋!