Hello,
I am using the NullObject Pattern which I find very convenient for not testing for nulls everywhere in my programs. I am using the Lifecycle callbacks to replace my NullObject by null when Hibernate saves / updates my classes and I instantiate a new NullObject when I load from Hibernate.
Here is the code for that.
Code:
// For Operation Null
public boolean onSave(Session s) throws CallbackException {
if (this.getOperation() instanceof OperationNullImpl)
this.setOperation(null);
return false;
}
public void onLoad(Session s, Serializable id) {
if (this.getOperation() == null)
this.setOperation(new OperationNullImpl());
}
The problem I have is that when I try to load, in this case, an operation which is null, Hibernate complains that I don't have a Persister for class 'OperationNullImpl'.
Do I really need a mapping for the OperationNullImpl class ? And if yes, how do I map it since I will never have a table in my database for null objects.
lacou