wiphillyfan wrote:
Thanks for the reply. Let me clarify, I already do have these attributes on the classes to be persisted and I am temporarily setting these values
as Calendar when I create instances of these classes on the client layer.
But, I want to set these values later on the server side so that they are more accurate as to when they are actually persisted.
I thought I could do this via the Interceptor interface by setting the values in the onSave() and onFlushDirty() methods, but that is not working - maybe I'm not doing it right. I have something like:
onSave()
{
if( entity instanceof Auditable )
{
((Auditable)entity).setCreateDate(Calendar.getInstance());
}
return false;
}
Is this the wrong way of doing this?
You can use an Interceptor to do it but, and I don't have my code in front of me, I believe that the object is already in a state where it's ready to be persisted so you can't change the "entity", you have to loop through the property names and then update the state[].
Actually, look at pages 128-129 of the 3.0.5 reference docs and it gives this exact example.