I have created one project in spring boot which is book-store . I have one post service which is used to take details of book and author also and save that into db [both book and author at same time].
I want to create a logic where i can save new book for already existing author but i tried several ways and im unable to do.
I need a way to do this
enter image description here
Here what i tried doing is i passed author email in path variable and passing a new book object as a json . i created a service which used to fetch particular author from db and i set that author object to my book object but it is saving that author object again and it is creating duplicate entry for that
author table:
here you can see duplicate entry of same author happend which i dont want
enter image description here
book table:
book table is correct here new book got saved
enter image description here
github link
this is my github link you can take a code and please help me to solve this issue . thanks in advance
Shubham Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.