Hi!
I'm having problems with an Hibernate Interceptor:
Here is the code I'm using:
Code:
public class UserLogInterceptorProxy extends EmptyInterceptor {
public boolean onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
Client client = (Client) entity;
client.setName("interceptor");
client.setAddress("interceptor");
client.setAlias("interceptor");
return true;
}
}
This is not what I really want to do, but I've set this values for test purpose.
After hibernate triggers the interceptor client is not saved with the new values I've set in the interceptor. It is saved with the values that were set before the interceptor was executed.
I've debugged Hibernate code and I see that when values are being replaced after interceptor execution, the values array contains the old values and are being replaced in the Client object so the result is the same object as the original.
I have followed this example:
http://hibernate.javabeat.net/articles/ ... oduction/3
What do I have to replace in the onSave method to set the new values to Client? Do I have to update the state array instead of the entity object?
Thank you in advance.