Skip to content

Commit e3f5449

Browse files
committed
Fix warnings in LocalSessionFactoryBean
1 parent 045c97f commit e3f5449

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
import java.util.Enumeration;
2727
import java.util.Map;
2828
import java.util.Properties;
29+
2930
import javax.sql.DataSource;
3031
import javax.transaction.TransactionManager;
3132

3233
import org.hibernate.HibernateException;
3334
import org.hibernate.Interceptor;
3435
import org.hibernate.Session;
3536
import org.hibernate.SessionFactory;
36-
import org.hibernate.cache.CacheProvider;
3737
import org.hibernate.cfg.Configuration;
3838
import org.hibernate.cfg.Environment;
3939
import org.hibernate.cfg.NamingStrategy;
@@ -43,7 +43,6 @@
4343
import org.hibernate.event.EventListeners;
4444
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
4545
import org.hibernate.transaction.JTATransactionFactory;
46-
4746
import org.springframework.beans.BeanUtils;
4847
import org.springframework.beans.factory.BeanClassLoaderAware;
4948
import org.springframework.core.io.ClassPathResource;
@@ -115,8 +114,9 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
115114
private static final ThreadLocal<Object> configTimeRegionFactoryHolder =
116115
new ThreadLocal<Object>();
117116

118-
private static final ThreadLocal<CacheProvider> configTimeCacheProviderHolder =
119-
new ThreadLocal<CacheProvider>();
117+
@SuppressWarnings("deprecation")
118+
private static final ThreadLocal<org.hibernate.cache.CacheProvider> configTimeCacheProviderHolder =
119+
new ThreadLocal<org.hibernate.cache.CacheProvider>();
120120

121121
private static final ThreadLocal<LobHandler> configTimeLobHandlerHolder =
122122
new ThreadLocal<LobHandler>();
@@ -167,7 +167,8 @@ static Object getConfigTimeRegionFactory() {
167167
* during configuration.
168168
* @see #setCacheProvider
169169
*/
170-
public static CacheProvider getConfigTimeCacheProvider() {
170+
@SuppressWarnings("deprecation")
171+
public static org.hibernate.cache.CacheProvider getConfigTimeCacheProvider() {
171172
return configTimeCacheProviderHolder.get();
172173
}
173174

@@ -207,7 +208,8 @@ public static LobHandler getConfigTimeLobHandler() {
207208

208209
private Object cacheRegionFactory;
209210

210-
private CacheProvider cacheProvider;
211+
@SuppressWarnings("deprecation")
212+
private org.hibernate.cache.CacheProvider cacheProvider;
211213

212214
private LobHandler lobHandler;
213215

@@ -401,7 +403,7 @@ public void setCacheRegionFactory(Object cacheRegionFactory) {
401403
* @see #setCacheRegionFactory
402404
*/
403405
@Deprecated
404-
public void setCacheProvider(CacheProvider cacheProvider) {
406+
public void setCacheProvider(org.hibernate.cache.CacheProvider cacheProvider) {
405407
this.cacheProvider = cacheProvider;
406408
}
407409

@@ -650,7 +652,7 @@ protected SessionFactory buildSessionFactory() throws Exception {
650652
}
651653

652654
if (dataSource != null) {
653-
Class providerClass = LocalDataSourceConnectionProvider.class;
655+
Class<?> providerClass = LocalDataSourceConnectionProvider.class;
654656
if (isUseTransactionAwareDataSource() || dataSource instanceof TransactionAwareDataSourceProxy) {
655657
providerClass = TransactionAwareDataSourceConnectionProvider.class;
656658
}
@@ -719,7 +721,7 @@ else if (this.cacheProvider != null) {
719721

720722
if (this.entityCacheStrategies != null) {
721723
// Register cache strategies for mapped entities.
722-
for (Enumeration classNames = this.entityCacheStrategies.propertyNames(); classNames.hasMoreElements();) {
724+
for (Enumeration<?> classNames = this.entityCacheStrategies.propertyNames(); classNames.hasMoreElements();) {
723725
String className = (String) classNames.nextElement();
724726
String[] strategyAndRegion =
725727
StringUtils.commaDelimitedListToStringArray(this.entityCacheStrategies.getProperty(className));
@@ -739,7 +741,7 @@ else if (strategyAndRegion.length > 0) {
739741

740742
if (this.collectionCacheStrategies != null) {
741743
// Register cache strategies for mapped collections.
742-
for (Enumeration collRoles = this.collectionCacheStrategies.propertyNames(); collRoles.hasMoreElements();) {
744+
for (Enumeration<?> collRoles = this.collectionCacheStrategies.propertyNames(); collRoles.hasMoreElements();) {
743745
String collRole = (String) collRoles.nextElement();
744746
String[] strategyAndRegion =
745747
StringUtils.commaDelimitedListToStringArray(this.collectionCacheStrategies.getProperty(collRole));
@@ -938,6 +940,7 @@ public void updateDatabaseSchema() throws DataAccessException {
938940
hibernateTemplate.execute(
939941
new HibernateCallback<Object>() {
940942
public Object doInHibernate(Session session) throws HibernateException, SQLException {
943+
@SuppressWarnings("deprecation")
941944
Connection con = session.connection();
942945
DatabaseMetadata metadata = new DatabaseMetadata(con, dialect);
943946
String[] sql = getConfiguration().generateSchemaUpdateScript(dialect, metadata);
@@ -982,6 +985,7 @@ public void validateDatabaseSchema() throws DataAccessException {
982985
hibernateTemplate.execute(
983986
new HibernateCallback<Object>() {
984987
public Object doInHibernate(Session session) throws HibernateException, SQLException {
988+
@SuppressWarnings("deprecation")
985989
Connection con = session.connection();
986990
DatabaseMetadata metadata = new DatabaseMetadata(con, dialect, false);
987991
getConfiguration().validateSchema(dialect, metadata);
@@ -1018,6 +1022,7 @@ public void dropDatabaseSchema() throws DataAccessException {
10181022
hibernateTemplate.execute(
10191023
new HibernateCallback<Object>() {
10201024
public Object doInHibernate(Session session) throws HibernateException, SQLException {
1025+
@SuppressWarnings("deprecation")
10211026
Connection con = session.connection();
10221027
String[] sql = getConfiguration().generateDropSchemaScript(dialect);
10231028
executeSchemaScript(con, sql);
@@ -1054,6 +1059,7 @@ public void createDatabaseSchema() throws DataAccessException {
10541059
hibernateTemplate.execute(
10551060
new HibernateCallback<Object>() {
10561061
public Object doInHibernate(Session session) throws HibernateException, SQLException {
1062+
@SuppressWarnings("deprecation")
10571063
Connection con = session.connection();
10581064
String[] sql = getConfiguration().generateSchemaCreationScript(dialect);
10591065
executeSchemaScript(con, sql);

0 commit comments

Comments
 (0)