Hi,
I was experiencing a weird problem using hibernate3 in an application based on the Spring-Framework, which I would regard at least as a design flaw of hibernate:
I was trying to use ehCache within my application and provided a configuration-file via Spring framework's EhCacheManagerFactoryBean. This worked well unless I started using hibernate, afterwards my EhCache-Configuration seemed to be ignored.
It seems that hibernate instantiates the CacheManager of ehCache without being told to do so (I never explicitly configured caching for hibernate) just when the library is available. Since the ehCache CacheManager is designed as a singleton, it happens that hibernate comes first and instantiates the CacheManager with its default configuration. The later instantiation of ehCache by the EhCacheManagerFactoryBean of the Spring Framework just returns the instance with the default configuration.
I simply solved the problem by making sure that the EhCacheManagerFactoryBean is instantiated before hibernate's SessionFactory.
I was just wondering if anybody experienced similar problems or knows if the assumption that ehCache is instantiated by hibernate just upon availability of the library is correct. In that case I would call it a bug...
Regards,
Christoph
|