posted 1 year ago
I make a blog on Spring Boot + Spring Date
There is a post, user, comment, and entities that contain links between them.
For each of these 6 entities, I added the annotation
Also created in the Database additionally hibernate_sequencе
However, the following problems arise.
1) When I add a post (with id = 1) and delete it, and then create a new post, it is already with id 2, not id 1
2) When I try to add a comment to it,then throws an error that usually occurs if there is no SequenceGenerator.
ERROR: insert or update on table "posts_comments" violates foreign key constraint "posts_comments_post_id_fkey"
DETAIL: Key (post_id) = (5) is not present in table
Why?
add comment in CommentService
Comment
Post
User