Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • 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: 17278
6
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic