Using Hibernate with Spring 3

My current web development tool is Spring 3, I used to use Hibernate, I am really familiar with it after I have access to annotations and objects, as well as to the session object. However, this will be my first time to install it from scratch.

I currently have a data source that I used for JDBCTemplate, and I want to use it for Hibernate.

Unfortunately, the more I read about Hibernate, the more I get embarrassed. There are many different ways to customize, and some have changed a bit since then. The most confusing is that sometimes the persistence.xml file is used, sometimes the hibernate config configuration file.

Then there are session factories, but then there are also object manager factories. Maybe someone wants to overtake some of this information, so I have a slightly clearer path ahead of me.

My only real requirements are that I can use annotations with Hibernate. I would also like to support transactions.

I know this question is somewhat vague, but this is because I could not find a reliable "legitimate" solution, relevant with Spring 3, which I trust.

+3
source share
1 answer

I currently have a data source that I used for JDBCTemplate, and I want to use it for Hibernate.

. , Hibernate JDBC .

(...) , persistence.xml, hibernate config.

hibernate.cfg.xml - Hibernate. persistence.xml - JPA ( Java Persistence API). JPA ( ), persistence.xml. Spring, Spring .

, . - , .

, . SessionFactory ( Session) - Hibernate native API, EntityManagerFactory EntityManager - - JPA-. JPA, EntityManagerFactory EntityManager.

, Hibernate. .

, API JPA ( Hibernate ). Spring.

12.6. JPA , Spring ( LocalContainerEntityManagerFactoryBean, 'll feed ).

(DAO) JpaTemplate JpaDaoSupport DAO JPA EntityManagerFactory EntityManager ( ).

Spring 2.5 - Spring 3.0. , , .

.

+3

Source: https://habr.com/ru/post/1753948/


All Articles