Now, let's see how to implement the saveMessage() method using Hibernate. First of all, let's update the pom.xml file to add the following two required dependencies:
<dependencies> ... <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency></dependencies>
The spring-orm library is Spring's ORM support, based on ORM technologies such as Hibernate. And the hibernate-core library is the Hibernate ORM framework.
Now, let's provide some metadata to Hibernate so that it knows how to map a Message object to the records in the messages table. Here, we will use the JPA annotation to add these metadata ...