I thank you very much for your suggestion. I tried it in a stand-alone application and it worked just fine. In this test, I set the listener using the setListener method in the Configuration interface. However, I have to deploy the application in a JBoss environment automatically configured using a hibernate-service.xml file. As it only exposes (through JNDI lookup) the resulting session factory (that does not keep a reference to the original configuration) I was not able to set the listener in the same way.
I have got it working by changing the listeners of my current session as shown below:
Code:
Session s = sessionFactory.getCurrentSession();
SessionImpl sImpl = (SessionImpl) s;
EventListeners listeners = sImpl.getListeners();
listeners.setPostLoadEventListeners(new PostLoadEventListener[]{this});
I still wonder if there is a more canonical way to set the posLoad listener in this case.