restored Hibernate 3.2 compatibility (SPR-6387)
This commit is contained in:
parent
8546e64b03
commit
1cf0c12674
|
|
@ -42,7 +42,7 @@ public class LocalRegionFactoryProxy implements RegionFactory {
|
||||||
|
|
||||||
|
|
||||||
public LocalRegionFactoryProxy() {
|
public LocalRegionFactoryProxy() {
|
||||||
RegionFactory rf = LocalSessionFactoryBean.getConfigTimeRegionFactory();
|
RegionFactory rf = (RegionFactory) LocalSessionFactoryBean.getConfigTimeRegionFactory();
|
||||||
// absolutely needs thread-bound RegionFactory to initialize
|
// absolutely needs thread-bound RegionFactory to initialize
|
||||||
if (rf == null) {
|
if (rf == null) {
|
||||||
throw new IllegalStateException("No Hibernate RegionFactory found - " +
|
throw new IllegalStateException("No Hibernate RegionFactory found - " +
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ import org.hibernate.Interceptor;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cache.CacheProvider;
|
import org.hibernate.cache.CacheProvider;
|
||||||
import org.hibernate.cache.RegionFactory;
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.cfg.NamingStrategy;
|
import org.hibernate.cfg.NamingStrategy;
|
||||||
|
|
@ -90,13 +89,11 @@ import org.springframework.util.StringUtils;
|
||||||
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewFilter} /
|
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewFilter} /
|
||||||
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor}.
|
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor}.
|
||||||
*
|
*
|
||||||
* <p><b>Requires Hibernate 3.3 or later.</b> Note that this factory will use
|
* <p><b>Requires Hibernate 3.2 or later, with Hibernate 3.3 being recommended.</b>
|
||||||
* "on_close" as default Hibernate connection release mode, unless in the
|
* Note that this factory will use "on_close" as default Hibernate connection
|
||||||
* case of a "jtaTransactionManager" specified, for the reason that
|
* release mode, unless in the case of a "jtaTransactionManager" specified,
|
||||||
* this is appropriate for most Spring-based applications (in particular when
|
* for the reason that this is appropriate for most Spring-based applications
|
||||||
* using Spring's HibernateTransactionManager). Hibernate 3.0 used "on_close"
|
* (in particular when using Spring's HibernateTransactionManager).
|
||||||
* as its own default too; however, Hibernate 3.1 changed this to "auto"
|
|
||||||
* (i.e. "after_statement" or "after_transaction").
|
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
|
|
@ -115,8 +112,8 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
|
||||||
private static final ThreadLocal<TransactionManager> configTimeTransactionManagerHolder =
|
private static final ThreadLocal<TransactionManager> configTimeTransactionManagerHolder =
|
||||||
new ThreadLocal<TransactionManager>();
|
new ThreadLocal<TransactionManager>();
|
||||||
|
|
||||||
private static final ThreadLocal<RegionFactory> configTimeRegionFactoryHolder =
|
private static final ThreadLocal<Object> configTimeRegionFactoryHolder =
|
||||||
new ThreadLocal<RegionFactory>();
|
new ThreadLocal<Object>();
|
||||||
|
|
||||||
private static final ThreadLocal<CacheProvider> configTimeCacheProviderHolder =
|
private static final ThreadLocal<CacheProvider> configTimeCacheProviderHolder =
|
||||||
new ThreadLocal<CacheProvider>();
|
new ThreadLocal<CacheProvider>();
|
||||||
|
|
@ -158,7 +155,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
|
||||||
* during configuration.
|
* during configuration.
|
||||||
* @see #setCacheRegionFactory
|
* @see #setCacheRegionFactory
|
||||||
*/
|
*/
|
||||||
public static RegionFactory getConfigTimeRegionFactory() {
|
static Object getConfigTimeRegionFactory() {
|
||||||
return configTimeRegionFactoryHolder.get();
|
return configTimeRegionFactoryHolder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,7 +205,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
|
||||||
|
|
||||||
private TransactionManager jtaTransactionManager;
|
private TransactionManager jtaTransactionManager;
|
||||||
|
|
||||||
private RegionFactory cacheRegionFactory;
|
private Object cacheRegionFactory;
|
||||||
|
|
||||||
private CacheProvider cacheProvider;
|
private CacheProvider cacheProvider;
|
||||||
|
|
||||||
|
|
@ -384,11 +381,13 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
|
||||||
* Allows for using a Spring-managed RegionFactory instance.
|
* Allows for using a Spring-managed RegionFactory instance.
|
||||||
* <p>As of Hibernate 3.3, this is the preferred mechanism for configuring
|
* <p>As of Hibernate 3.3, this is the preferred mechanism for configuring
|
||||||
* caches, superseding the {@link #setCacheProvider CacheProvider SPI}.
|
* caches, superseding the {@link #setCacheProvider CacheProvider SPI}.
|
||||||
|
* For Hibernate 3.2 compatibility purposes, the accepted reference is of type
|
||||||
|
* Object: the actual type is <code>org.hibernate.cache.RegionFactory</code>.
|
||||||
* <p>Note: If this is set, the Hibernate settings should not define a
|
* <p>Note: If this is set, the Hibernate settings should not define a
|
||||||
* cache provider to avoid meaningless double configuration.
|
* cache provider to avoid meaningless double configuration.
|
||||||
* @see LocalRegionFactoryProxy
|
* @see org.hibernate.cache.RegionFactory
|
||||||
*/
|
*/
|
||||||
public void setCacheRegionFactory(RegionFactory cacheRegionFactory) {
|
public void setCacheRegionFactory(Object cacheRegionFactory) {
|
||||||
this.cacheRegionFactory = cacheRegionFactory;
|
this.cacheRegionFactory = cacheRegionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -664,7 +663,8 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
|
||||||
|
|
||||||
if (this.cacheRegionFactory != null) {
|
if (this.cacheRegionFactory != null) {
|
||||||
// Expose Spring-provided Hibernate RegionFactory.
|
// Expose Spring-provided Hibernate RegionFactory.
|
||||||
config.setProperty(Environment.CACHE_REGION_FACTORY, LocalRegionFactoryProxy.class.getName());
|
config.setProperty(Environment.CACHE_REGION_FACTORY,
|
||||||
|
"org.springframework.orm.hibernate3.LocalRegionFactoryProxy");
|
||||||
}
|
}
|
||||||
else if (this.cacheProvider != null) {
|
else if (this.cacheProvider != null) {
|
||||||
// Expose Spring-provided Hibernate CacheProvider.
|
// Expose Spring-provided Hibernate CacheProvider.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue