Skip to content

Commit 1cf0c12

Browse files
committed
restored Hibernate 3.2 compatibility (SPR-6387)
1 parent 8546e64 commit 1cf0c12

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

org.springframework.orm/src/main/java/org/springframework/orm/hibernate3/LocalRegionFactoryProxy.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class LocalRegionFactoryProxy implements RegionFactory {
4242

4343

4444
public LocalRegionFactoryProxy() {
45-
RegionFactory rf = LocalSessionFactoryBean.getConfigTimeRegionFactory();
45+
RegionFactory rf = (RegionFactory) LocalSessionFactoryBean.getConfigTimeRegionFactory();
4646
// absolutely needs thread-bound RegionFactory to initialize
4747
if (rf == null) {
4848
throw new IllegalStateException("No Hibernate RegionFactory found - " +

org.springframework.orm/src/main/java/org/springframework/orm/hibernate3/LocalSessionFactoryBean.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.hibernate.Session;
3535
import org.hibernate.SessionFactory;
3636
import org.hibernate.cache.CacheProvider;
37-
import org.hibernate.cache.RegionFactory;
3837
import org.hibernate.cfg.Configuration;
3938
import org.hibernate.cfg.Environment;
4039
import org.hibernate.cfg.NamingStrategy;
@@ -90,13 +89,11 @@
9089
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewFilter} /
9190
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor}.
9291
*
93-
* <p><b>Requires Hibernate 3.3 or later.</b> Note that this factory will use
94-
* "on_close" as default Hibernate connection release mode, unless in the
95-
* case of a "jtaTransactionManager" specified, for the reason that
96-
* this is appropriate for most Spring-based applications (in particular when
97-
* using Spring's HibernateTransactionManager). Hibernate 3.0 used "on_close"
98-
* as its own default too; however, Hibernate 3.1 changed this to "auto"
99-
* (i.e. "after_statement" or "after_transaction").
92+
* <p><b>Requires Hibernate 3.2 or later, with Hibernate 3.3 being recommended.</b>
93+
* Note that this factory will use "on_close" as default Hibernate connection
94+
* release mode, unless in the case of a "jtaTransactionManager" specified,
95+
* for the reason that this is appropriate for most Spring-based applications
96+
* (in particular when using Spring's HibernateTransactionManager).
10097
*
10198
* @author Juergen Hoeller
10299
* @since 1.2
@@ -115,8 +112,8 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
115112
private static final ThreadLocal<TransactionManager> configTimeTransactionManagerHolder =
116113
new ThreadLocal<TransactionManager>();
117114

118-
private static final ThreadLocal<RegionFactory> configTimeRegionFactoryHolder =
119-
new ThreadLocal<RegionFactory>();
115+
private static final ThreadLocal<Object> configTimeRegionFactoryHolder =
116+
new ThreadLocal<Object>();
120117

121118
private static final ThreadLocal<CacheProvider> configTimeCacheProviderHolder =
122119
new ThreadLocal<CacheProvider>();
@@ -158,7 +155,7 @@ public static TransactionManager getConfigTimeTransactionManager() {
158155
* during configuration.
159156
* @see #setCacheRegionFactory
160157
*/
161-
public static RegionFactory getConfigTimeRegionFactory() {
158+
static Object getConfigTimeRegionFactory() {
162159
return configTimeRegionFactoryHolder.get();
163160
}
164161

@@ -208,7 +205,7 @@ public static LobHandler getConfigTimeLobHandler() {
208205

209206
private TransactionManager jtaTransactionManager;
210207

211-
private RegionFactory cacheRegionFactory;
208+
private Object cacheRegionFactory;
212209

213210
private CacheProvider cacheProvider;
214211

@@ -384,11 +381,13 @@ public void setJtaTransactionManager(TransactionManager jtaTransactionManager) {
384381
* Allows for using a Spring-managed RegionFactory instance.
385382
* <p>As of Hibernate 3.3, this is the preferred mechanism for configuring
386383
* caches, superseding the {@link #setCacheProvider CacheProvider SPI}.
384+
* For Hibernate 3.2 compatibility purposes, the accepted reference is of type
385+
* Object: the actual type is <code>org.hibernate.cache.RegionFactory</code>.
387386
* <p>Note: If this is set, the Hibernate settings should not define a
388387
* cache provider to avoid meaningless double configuration.
389-
* @see LocalRegionFactoryProxy
388+
* @see org.hibernate.cache.RegionFactory
390389
*/
391-
public void setCacheRegionFactory(RegionFactory cacheRegionFactory) {
390+
public void setCacheRegionFactory(Object cacheRegionFactory) {
392391
this.cacheRegionFactory = cacheRegionFactory;
393392
}
394393

@@ -664,7 +663,8 @@ else if (config.getProperty(Environment.TRANSACTION_MANAGER_STRATEGY) != null) {
664663

665664
if (this.cacheRegionFactory != null) {
666665
// Expose Spring-provided Hibernate RegionFactory.
667-
config.setProperty(Environment.CACHE_REGION_FACTORY, LocalRegionFactoryProxy.class.getName());
666+
config.setProperty(Environment.CACHE_REGION_FACTORY,
667+
"org.springframework.orm.hibernate3.LocalRegionFactoryProxy");
668668
}
669669
else if (this.cacheProvider != null) {
670670
// Expose Spring-provided Hibernate CacheProvider.

0 commit comments

Comments
 (0)