1. if you are overriding equals and hashcode on you hibernate object, make sure you aren't referencing id instances variables directly.
2. if updates to your object aren't getting committed make sure there is a version column on the object you are proxying.
handy hibernate logging levels to dynamically see what is going on:
Logger.getLogger("net.sf.hibernate.impl.BatcherImpl").setLevel(Level.FINE);
Logger.getLogger("net.sf.hibernate.impl.SessionImpl").setLevel(Level.FINE);
Logger.getLogger("net.sf.hibernate.SQL").setLevel(Level.FINE);
Logger.getLogger("net.sf.hibernate.persister.AbstractEntityPersister").setLevel(Level.ALL);
}
2 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Hi Brett,
Nice to see you blogging again. I am sure time is still hard to find.
Just wondering though, what happens if you violate rule number 1?
if you violate rule number 1, you will get unpredictable results eg. like updates to an object not being recognised as dirty and not getting flushed to the db.
The proxy itself has an id, so if your equals method is not calling getId() then you will be comparing the proxys’ id to said entity instance id and not get a match.