• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate mapping: Update a set property

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Hibernate mapping containing a set. The set is defined in the mapping like this:



When I update the Audit entity I also want to update the set of auditLogs within this entity. This fails.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add the cascading options in your mapping. Cascade options tell Hibernate what to do with the objects in the Collection. Without it Hibernate will only load it on reading, but not keep track of changes to the Collection for you.

So you want cascade option all. And if you want the children to be deleted when the parent gets deleted, then you also want Hibernate's orphan-delete cascade option.

Mark
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!