Skip to content
Advertisement

Java spring Hibernate : Error when trying to implement a many to one relationship

I am trying to implement a many to one relationship with a user being able to have many posts. The used database is postgresql.

The error I have is the following and is caused by Hibernate: alter table post drop constraint FKl1p5mt95jngsghp4vtaw04egh :

JavaScript

These are the 2 classes I use :

JavaScript

and

JavaScript

The error occurs at the initialisation of the program before any kind of requests.

The spring.jpa.hibernate.ddl-auto is set to create so there should not be any interference from previous tables / values in my understanding.

What is causing this error ?

I am including a screen of the generated database as seen in jetbrains Idea just in case :

enter image description here

Advertisement

Answer

Your definitions don’t look to bad, and looking at the error, I would assume it’s comming from the create setting – why else Hibernate would try to drop any constraint. Can you delete your database/tables manually and try to run the program again?

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement