Waswani Naresh wrote:
Hi Andrej,
Hello, Waswani
thank you for reply
Waswani Naresh wrote:
In the AuthorDAOImpl's updateAuthor(), where the Author object gets passed...
1) The author has the department object fully populated. From where the department object is retrieved...I mean, before saving the author are you getting the department object in a different query OR it is taken from some list in the memory ?
Well, here I just get
Author object in
AuthorController and pass it to
AuthorService which passes object to aforementioned
AuthorDAO. Nothing more is done. I've googled a lot and found very similar
issue. So in my case Spring or Hibernate also don't know which department I am trying to update and can't map it to department in database. Maybe I'm passing wrongly list of departments in
AuthorController.
Waswani Naresh wrote:
2) In your scenario, you are not changing the author's department but some other attribute of author ? Is this correct ?
Correct. Also my previous code inserted departments ID as name of department, but I've changed line with form:options from
to
Now to reproduce exception I have to load update page and click on button. Exception occurs every time, because all values which are in select are also in database. And I have
@Column(name="name", unique=true) to prevent duplicates. I don't need to change department table in database at all, I just need to change departments foreign key in authors table.
Waswani Naresh wrote:
3) Before saving the author, both the department and the author object are in detached mode ? Is this correct ?
I didn't knew what
detached mode means so I've googled and found it in
hibernate documentation. And as far as I know I'm not doing any detaching unless hibernate does it by itself.