Skip to content


Hibernate 2 Proxies – Lessons Learnt

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);
}

Post to Twitter Tweet This Post

Posted in Uncategorized. Tagged with .

2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Anonymous said

    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?

  2. Anonymous said

    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.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.


Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.