I am quite new to Spring and have a task to create a multi-module project that needs to use Hibernate JPA and Spring-Boot (Spring Data JPA is not allowed for this project).
I am using the PostgreSQL database and org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final
.
I added hibernate JPA and on its own, it works but I don't know how to configure it to work in my spring-boot project. And most examples use spring-data-jpa.
I tried @PersitenceContect
annotation for my EntityManager but that doesn't work.
I also tried following this: https://allaroundjava.com/hibernate-jpa-spring-tutorial/ But maybe because of different databases or maybe smth else I couldn't get it to work.
CodePudding user response:
You have to add hibernate jpa dependency if you want to work with Hibernate JPA
.
Add this dependency in pom.xml
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
For further information look here https://www.infoworld.com/article/3373652/java-persistence-with-jpa-and-hibernate-part-1-entities-and-relationships.html?page=2
CodePudding user response:
A great tutorial with an example (with postgres) is the following one : https://www.bezkoder.com/spring-boot-postgresql-example/
It shows how to structure your file structure (etc) which is nice.