I'm looking at creating a system where all persistent objects have a cleanupDate field, and to delete an item, you just set the cleanup date to the current date. All persistent objects in my system extend a common class and I thought I could just implement something like this for the onDelete() method in that class (which extends Lifecycle):
Code:
public boolean onDelete(Session aSession) throws CallbackException {
logger.debug("onDelete() called.");
this.setCleanupDate(new Date());
try {
aSession.saveOrUpdate(this);
} catch (HibernateException e) {
throw new CallbackException("Couldn't update cleanup date.", e);
}
return VETO;
}
The onDelete() method is being called, but despite the fact that I'm returning VETO, the delete goes ahead and runs.
Any ideas what I'm missing here?
I'm also examining ways to automatically filter items with cleanup dates in the past when results are returned. I haven't looked into it much, but any pointers to easy hooks that I could take advantage of for this functionality would be helpful.