-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for the HIbernate RegionFactory cache API to LocalSessionFactoryBean [SPR-6387] #11053
Comments
Juergen Hoeller commented Good idea. LocalSessionFactoryBean has a corresponding "cacheRegionFactory" property now. Juergen |
Ben Corrie commented Unfortunately, this seems to have broken Spring with any version of Hibernate before 3.3.x. You get a NoClassDefFoundError for org/hibernate/cache/RegionFactory thrown from targetClass.getDeclaredFields() in PersistenceAnnotationBeanPostProcessor when targetClass == LocalSessionFactoryBean. Is it intentional to make Spring 3.0 require Hibernate 3.3.x? Ben |
Juergen Hoeller commented Indeed, RegionFactory is a Hibernate 3.3+ interface. In order to properly support it, LocalSessionFactoryBean requires Hibernate 3.3 or above there. Admittedly, that requirement is a bit unfortunate just for the purpose of supporting the RegionFactory SPI... So I've changed this to accepting a RegionFactory as Object and simply passing it through: preserving compatibility with Hibernate 3.2, while explicitly supporting and recommending the use of Hibernate 3.3. Note that we have been supporting Hibernate 3.5 betas for a while as well: Hibernate 3.5 is the first JPA 2.0 compatible release with some fairly significant changes to Hibernate core as well, which we're supporting in Spring 3.0 for the first time. So Spring 3.0 is primarily about Hibernate 3.3 and 3.5 now, with Hibernate 3.2 support being possible (again) but effectively being deprecated in favor of Hibernate 3.3 as the mainstream release to use. Juergen |
Manuel Dominguez Sarmiento commented SettingsFactory.createRegionFactory() has this code which does not work with LocalRegionFactoryProxy, at least not in Hibernate 3.3.2:
LocalRegionFactoryProxy's only constructor is parameterless, so this fails with this stack trace: java.lang.NoSuchMethodException: org.springframework.orm.hibernate3.LocalRegionFactoryProxy.<init>(java.util.Properties) All RegionFactory implementations have a constructor that takes a Properties object as the only argument. It seems this is required by Hibernate, although of course this cannot be enforced by the interface. The interface's documentation does state that parameterless constructors are acceptable, but the code requires a contructor with a Properties argument. This is most likely a Hibernate bug, but it can be easily solved by adding an extra LocalRegionFactoryProxy(Properties) constructor. I'm downloading Hibernate 3.5 beta 4 to check whether this is still an issue. |
Manuel Dominguez Sarmiento commented Someone else is experiencing exactly the same problem: |
Manuel Dominguez Sarmiento commented Same issue with Hibernate 3.5 beta 4 |
Manuel Dominguez Sarmiento commented This is a Hibernate bug, but is unresolved. Not sure who should fix it. http://opensource.atlassian.com/projects/hibernate/browse/HHH-3695 |
Juergen Hoeller commented Thanks for pointing this out, Manuel! I've added such a LocalRegionFactoryProxy(Properties) constructor for Spring 3.0.1, simply ignoring the passed-in properties. Juergen |
Manuel Dominguez Sarmiento commented Hi Juergen, good to hear this. I've already created an issue at: http://jira.springframework.org/browse/SPR-6804 also take a look at this somewhat related issue with LocalRegionFactoryProxy: |
William Ashley opened SPR-6387 and commented
LocalSessionFactoryBean currently supports configuring hibernate with a spring-managed CacheProvider, however this API is deprecated and the new one is based on org.hibernate.cache.RegionFactory. It would be nice to have similar functionality in the LocalSessionFactoryBean for this new API.
Issue Links:
Referenced from: commits 1cf0c12, eb0b4f0
The text was updated successfully, but these errors were encountered: