Hi,
I'm using JBossAS 4.0.4 with Hibernate 3.0. I installed a SessionFactoryInterceptor and would like to compare the current persistent object state with a modified object's state.
The Interceptor interface provides a method findDirty with a previousState parameter reflecting the object state as it was when the current hibernate session started. The previousState array therefore does not reflect the current persistent state but a detached object's state.
Code:
public int[] findDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types)
What would be the best way to obtain the field values as currently stored in the database? HQL queries do not seem to work as they always return the current object version from the object cache (because this is the most recent object version).
I figured one could use a native SQL query to circumvent Hibernate's object cache. Where I encountered my next problem: how do I get the database table and column names for a persitent class? The ClassMetadata seems to contain property names but not the mapped field names for use in native queries.
Thanks in advance for any advice
Fritz