Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HibernateTemplate vs SessionFactory

Tags:

java

hibernate

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

like image 373
Paulius Matulionis Avatar asked Feb 21 '23 07:02

Paulius Matulionis


1 Answers

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.

like image 83
JB Nizet Avatar answered Mar 04 '23 12:03

JB Nizet