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 thesrc/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...