Hi, I am using an Interceptor so that I can validate values in my entity object just before they are saved. So, for example in the Interceptor's onSave() method I will throw an exception if some validation rule fails. The problem is that I want to continue using the same Session afterwards but I get an exception when the Session is flushed because the previous Entity object that failed validation still resides in some private structures of the Session. Evicting this object from the Session when a validation error occurs fails also (I get an AssertionFailure because the failed entity doesn't have an id). Am I using the Interceptor wrong? Is there another way to do this? I suppose I could call clear() on the Session but I really would like to just remove the failed entity from the session's internal structures. NOTE, the exception that I raise in the Interceptor isn't a hibernate exception just a runtime check (business rule check) before I save, kinda like a JDO-like InstanceCallback.
Thanks for any help,
Mike
|