Hi,
Our application is deployed a little bit differently than usual. Hibernate is loaded and initialized by the main container classloader and the actual application is loaded by a child classloader (like a web application). The problem arises when the application is reloaded by discarding the child classloader and creating another one.
The problem is that when using scalar queries with a holder class (select new MyClass), after a reload hibernate will create instances of the holder class loaded using the old classloader. It seems that Hibernate actually holds a reference to this class somewhere. I did some research in the source code and it seems that the queries(QueryTranslator having the field holderClass) are stored in the private softQueryCache field of the SessionFactoryImpl which is never cleared and there is no publicly accessible methods that would allow this.
I would like the confirmation that the problem is really there. I've tried the method SessionFactory.evictQueries(), but it seems to clear something else. If the problem does exist when I will create a JIRA bug that hopefully will be fixed in the next version.
Thanks,
Peter.
|