dimanche 18 avril 2010

Hibernate: moving objects from one parent to another

Using Hibernate, I usually default collection "cascade" attribute to "all-delete-orphan". The allows me to not care about cascading at all, and let Hibernate do everything.

However, if you want to move an object from one parent to another (in my case, say a peep is removed from a FarmTile and added to a BoardTile or a Card), you will get an exception like "deleted object would be re-saved by cascade (remove deleted object from associations".

To solve this, simply change the 'all-delete-orphan" to "all" - which means you will need to manually delete orphans if you need them deleted though.

2 commentaires:

  1. You might be interested in my project
    www.agricolaonline.com

    I have actually neared completion of an online version of Agricola.

    RépondreSupprimer
  2. Has the development for the Agricola project ended? If it hasn't I would like to see what I could do to help!

    RépondreSupprimer