Setting up Hibernate with Spring
There are different approaches to integrating Hibernate with Spring. One of them represents defining Hibernate-related configuration in the XML application context file, and, the other one is based on the usage of appropriate annotations. In this section, you will learn to setup Hibernate with Spring using the annotation method.
In order to setup Hibernate with Spring, one would need to do following:
- Setting up data source information in theÂ
application.propertiesfile, which can be found in theÂsrc/main/resourcesfolder when working with a Spring Boot application. - Use annotations to wireÂ
LocalSessionFactoryBeaninto theSessionFactoryobject within DAO.
Setting up data source information in the application.properties file
Place the following configuration-related code in the application.properties file. The following code represents the database server address as 127.0.0.1:3306Â and the database as healthapp:
spring.datasource.driverClassName=com.mysql.jdbc...