Fix warnings in LocalSessionFactoryBean
This commit is contained in:
		
							parent
							
								
									045c97f75e
								
							
						
					
					
						commit
						e3f544904c
					
				|  | @ -26,6 +26,7 @@ import java.util.Collection; | ||||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.Properties; | import java.util.Properties; | ||||||
|  | 
 | ||||||
| import javax.sql.DataSource; | import javax.sql.DataSource; | ||||||
| import javax.transaction.TransactionManager; | import javax.transaction.TransactionManager; | ||||||
| 
 | 
 | ||||||
|  | @ -33,7 +34,6 @@ import org.hibernate.HibernateException; | ||||||
| import org.hibernate.Interceptor; | 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.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; | ||||||
|  | @ -43,7 +43,6 @@ import org.hibernate.engine.SessionFactoryImplementor; | ||||||
| import org.hibernate.event.EventListeners; | import org.hibernate.event.EventListeners; | ||||||
| import org.hibernate.tool.hbm2ddl.DatabaseMetadata; | import org.hibernate.tool.hbm2ddl.DatabaseMetadata; | ||||||
| import org.hibernate.transaction.JTATransactionFactory; | import org.hibernate.transaction.JTATransactionFactory; | ||||||
| 
 |  | ||||||
| import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||||
| import org.springframework.beans.factory.BeanClassLoaderAware; | import org.springframework.beans.factory.BeanClassLoaderAware; | ||||||
| import org.springframework.core.io.ClassPathResource; | import org.springframework.core.io.ClassPathResource; | ||||||
|  | @ -115,8 +114,9 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 	private static final ThreadLocal<Object> configTimeRegionFactoryHolder = | 	private static final ThreadLocal<Object> configTimeRegionFactoryHolder = | ||||||
| 			new ThreadLocal<Object>(); | 			new ThreadLocal<Object>(); | ||||||
| 
 | 
 | ||||||
| 	private static final ThreadLocal<CacheProvider> configTimeCacheProviderHolder = | 	@SuppressWarnings("deprecation") | ||||||
| 			new ThreadLocal<CacheProvider>(); | 	private static final ThreadLocal<org.hibernate.cache.CacheProvider> configTimeCacheProviderHolder = | ||||||
|  | 			new ThreadLocal<org.hibernate.cache.CacheProvider>(); | ||||||
| 
 | 
 | ||||||
| 	private static final ThreadLocal<LobHandler> configTimeLobHandlerHolder = | 	private static final ThreadLocal<LobHandler> configTimeLobHandlerHolder = | ||||||
| 			new ThreadLocal<LobHandler>(); | 			new ThreadLocal<LobHandler>(); | ||||||
|  | @ -167,7 +167,8 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 	 * during configuration. | 	 * during configuration. | ||||||
| 	 * @see #setCacheProvider | 	 * @see #setCacheProvider | ||||||
| 	 */ | 	 */ | ||||||
| 	public static CacheProvider getConfigTimeCacheProvider() { | 	@SuppressWarnings("deprecation") | ||||||
|  | 	public static org.hibernate.cache.CacheProvider getConfigTimeCacheProvider() { | ||||||
| 		return configTimeCacheProviderHolder.get(); | 		return configTimeCacheProviderHolder.get(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -207,7 +208,8 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 
 | 
 | ||||||
| 	private Object cacheRegionFactory; | 	private Object cacheRegionFactory; | ||||||
| 
 | 
 | ||||||
| 	private CacheProvider cacheProvider; | 	@SuppressWarnings("deprecation") | ||||||
|  | 	private org.hibernate.cache.CacheProvider cacheProvider; | ||||||
| 
 | 
 | ||||||
| 	private LobHandler lobHandler; | 	private LobHandler lobHandler; | ||||||
| 
 | 
 | ||||||
|  | @ -401,7 +403,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 	 * @see #setCacheRegionFactory | 	 * @see #setCacheRegionFactory | ||||||
| 	 */ | 	 */ | ||||||
| 	@Deprecated | 	@Deprecated | ||||||
| 	public void setCacheProvider(CacheProvider cacheProvider) { | 	public void setCacheProvider(org.hibernate.cache.CacheProvider cacheProvider) { | ||||||
| 		this.cacheProvider = cacheProvider; | 		this.cacheProvider = cacheProvider; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -650,7 +652,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if (dataSource != null) { | 			if (dataSource != null) { | ||||||
| 				Class providerClass = LocalDataSourceConnectionProvider.class; | 				Class<?> providerClass = LocalDataSourceConnectionProvider.class; | ||||||
| 				if (isUseTransactionAwareDataSource() || dataSource instanceof TransactionAwareDataSourceProxy) { | 				if (isUseTransactionAwareDataSource() || dataSource instanceof TransactionAwareDataSourceProxy) { | ||||||
| 					providerClass = TransactionAwareDataSourceConnectionProvider.class; | 					providerClass = TransactionAwareDataSourceConnectionProvider.class; | ||||||
| 				} | 				} | ||||||
|  | @ -719,7 +721,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 
 | 
 | ||||||
| 			if (this.entityCacheStrategies != null) { | 			if (this.entityCacheStrategies != null) { | ||||||
| 				// Register cache strategies for mapped entities. | 				// Register cache strategies for mapped entities. | ||||||
| 				for (Enumeration classNames = this.entityCacheStrategies.propertyNames(); classNames.hasMoreElements();) { | 				for (Enumeration<?> classNames = this.entityCacheStrategies.propertyNames(); classNames.hasMoreElements();) { | ||||||
| 					String className = (String) classNames.nextElement(); | 					String className = (String) classNames.nextElement(); | ||||||
| 					String[] strategyAndRegion = | 					String[] strategyAndRegion = | ||||||
| 							StringUtils.commaDelimitedListToStringArray(this.entityCacheStrategies.getProperty(className)); | 							StringUtils.commaDelimitedListToStringArray(this.entityCacheStrategies.getProperty(className)); | ||||||
|  | @ -739,7 +741,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 
 | 
 | ||||||
| 			if (this.collectionCacheStrategies != null) { | 			if (this.collectionCacheStrategies != null) { | ||||||
| 				// Register cache strategies for mapped collections. | 				// Register cache strategies for mapped collections. | ||||||
| 				for (Enumeration collRoles = this.collectionCacheStrategies.propertyNames(); collRoles.hasMoreElements();) { | 				for (Enumeration<?> collRoles = this.collectionCacheStrategies.propertyNames(); collRoles.hasMoreElements();) { | ||||||
| 					String collRole = (String) collRoles.nextElement(); | 					String collRole = (String) collRoles.nextElement(); | ||||||
| 					String[] strategyAndRegion = | 					String[] strategyAndRegion = | ||||||
| 							StringUtils.commaDelimitedListToStringArray(this.collectionCacheStrategies.getProperty(collRole)); | 							StringUtils.commaDelimitedListToStringArray(this.collectionCacheStrategies.getProperty(collRole)); | ||||||
|  | @ -938,6 +940,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 			hibernateTemplate.execute( | 			hibernateTemplate.execute( | ||||||
| 				new HibernateCallback<Object>() { | 				new HibernateCallback<Object>() { | ||||||
| 					public Object doInHibernate(Session session) throws HibernateException, SQLException { | 					public Object doInHibernate(Session session) throws HibernateException, SQLException { | ||||||
|  | 						@SuppressWarnings("deprecation") | ||||||
| 						Connection con = session.connection(); | 						Connection con = session.connection(); | ||||||
| 						DatabaseMetadata metadata = new DatabaseMetadata(con, dialect); | 						DatabaseMetadata metadata = new DatabaseMetadata(con, dialect); | ||||||
| 						String[] sql = getConfiguration().generateSchemaUpdateScript(dialect, metadata); | 						String[] sql = getConfiguration().generateSchemaUpdateScript(dialect, metadata); | ||||||
|  | @ -982,6 +985,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 			hibernateTemplate.execute( | 			hibernateTemplate.execute( | ||||||
| 				new HibernateCallback<Object>() { | 				new HibernateCallback<Object>() { | ||||||
| 					public Object doInHibernate(Session session) throws HibernateException, SQLException { | 					public Object doInHibernate(Session session) throws HibernateException, SQLException { | ||||||
|  | 						@SuppressWarnings("deprecation") | ||||||
| 						Connection con = session.connection(); | 						Connection con = session.connection(); | ||||||
| 						DatabaseMetadata metadata = new DatabaseMetadata(con, dialect, false); | 						DatabaseMetadata metadata = new DatabaseMetadata(con, dialect, false); | ||||||
| 						getConfiguration().validateSchema(dialect, metadata); | 						getConfiguration().validateSchema(dialect, metadata); | ||||||
|  | @ -1018,6 +1022,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 		hibernateTemplate.execute( | 		hibernateTemplate.execute( | ||||||
| 			new HibernateCallback<Object>() { | 			new HibernateCallback<Object>() { | ||||||
| 				public Object doInHibernate(Session session) throws HibernateException, SQLException { | 				public Object doInHibernate(Session session) throws HibernateException, SQLException { | ||||||
|  | 					@SuppressWarnings("deprecation") | ||||||
| 					Connection con = session.connection(); | 					Connection con = session.connection(); | ||||||
| 					String[] sql = getConfiguration().generateDropSchemaScript(dialect); | 					String[] sql = getConfiguration().generateDropSchemaScript(dialect); | ||||||
| 					executeSchemaScript(con, sql); | 					executeSchemaScript(con, sql); | ||||||
|  | @ -1054,6 +1059,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen | ||||||
| 			hibernateTemplate.execute( | 			hibernateTemplate.execute( | ||||||
| 				new HibernateCallback<Object>() { | 				new HibernateCallback<Object>() { | ||||||
| 					public Object doInHibernate(Session session) throws HibernateException, SQLException { | 					public Object doInHibernate(Session session) throws HibernateException, SQLException { | ||||||
|  | 						@SuppressWarnings("deprecation") | ||||||
| 						Connection con = session.connection(); | 						Connection con = session.connection(); | ||||||
| 						String[] sql = getConfiguration().generateSchemaCreationScript(dialect); | 						String[] sql = getConfiguration().generateSchemaCreationScript(dialect); | ||||||
| 						executeSchemaScript(con, sql); | 						executeSchemaScript(con, sql); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue