-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: What is "best practice" for cleaning up "garb
PostPosted: Mon Jun 19, 2006 3:50 am 
Newbie

Joined: Thu Jun 15, 2006 7:32 pm
Posts: 3
Can anyone recommend a good way to ensure that database rows representing "derefenced objects" are cleaned up? That is, how should I implement the equivalent of garbage-collection for my database?

Transitive persistence is truly handy, but as the Hibernate manual says:

Quote:
A child which becomes unreferenced by its parent is not automatically deleted, except in the case of a <one-to-many> association mapped with cascade="delete-orphan".


I have associations in my domain-model that don't naturally map to one-to-many, e.g.
  • one-to-{zero,one} associations, where a child object may be null, or replaced
  • many-to-many parent/child relationships where a child may be shared between "parents", but should be removed once it's no longer referenced


I accept that Hibernate can't help me in these situations. I imagine that calling session.delete() explicitly would work, but I don't want to tie my domain-model to Hibernate, and still want it to work sensibly even when not persisted.

So, how should I clean up data in these cases? What has worked for you?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.