Polishing

This commit is contained in:
Juergen Hoeller 2014-01-27 22:41:35 +01:00
parent 1b0ce200e0
commit 500d0da67d
6 changed files with 33 additions and 27 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,11 +44,15 @@ import org.springframework.core.io.support.ResourcePatternUtils;
* Hibernate SessionFactory in a Spring application context; the SessionFactory can * Hibernate SessionFactory in a Spring application context; the SessionFactory can
* then be passed to Hibernate-based data access objects via dependency injection. * then be passed to Hibernate-based data access objects via dependency injection.
* *
* <p><b>NOTE:</b> This variant of LocalSessionFactoryBean requires Hibernate 4.0 or higher. * <p><b>This variant of LocalSessionFactoryBean requires Hibernate 4.0 or higher.</b>
* As of Spring 4.0, it is compatible with (the quite refactored) Hibernate 4.3 as well. * As of Spring 4.0, it is compatible with (the quite refactored) Hibernate 4.3 as well.
* It is similar in role to the same-named class in the {@code orm.hibernate3} package. * We recommend using the latest Hibernate 4.2.x or 4.3.x version, depending on whether
* However, in practice, it is closer to {@code AnnotationSessionFactoryBean} since * you need to remain JPA 2.0 compatible at runtime (Hibernate 4.2) or can upgrade to
* its core purpose is to bootstrap a {@code SessionFactory} from annotation scanning. * JPA 2.1 (Hibernate 4.3).
*
* <p>This class is similar in role to the same-named class in the {@code orm.hibernate3}
* package. However, in practice, it is closer to {@code AnnotationSessionFactoryBean}
* since its core purpose is to bootstrap a {@code SessionFactory} from package scanning.
* *
* <p><b>NOTE:</b> To set up Hibernate 4 for Spring-driven JTA transactions, make * <p><b>NOTE:</b> To set up Hibernate 4 for Spring-driven JTA transactions, make
* sure to either specify the {@link #setJtaTransactionManager "jtaTransactionManager"} * sure to either specify the {@link #setJtaTransactionManager "jtaTransactionManager"}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,8 +62,10 @@ import org.springframework.util.ClassUtils;
* <p>This is designed for programmatic use, e.g. in {@code @Bean} factory methods. * <p>This is designed for programmatic use, e.g. in {@code @Bean} factory methods.
* Consider using {@link LocalSessionFactoryBean} for XML bean definition files. * Consider using {@link LocalSessionFactoryBean} for XML bean definition files.
* *
* <p>Requires Hibernate 4.0 or higher. As of Spring 4.0, it is compatible with * <p><b>Requires Hibernate 4.0 or higher.</b> As of Spring 4.0, it is compatible with
* (the quite refactored) Hibernate 4.3 as well. * (the quite refactored) Hibernate 4.3 as well. We recommend using the latest
* Hibernate 4.2.x or 4.3.x version, depending on whether you need to remain JPA 2.0
* compatible at runtime (Hibernate 4.2) or can upgrade to JPA 2.1 (Hibernate 4.3).
* *
* <p><b>NOTE:</b> To set up Hibernate 4 for Spring-driven JTA transactions, make * <p><b>NOTE:</b> To set up Hibernate 4 for Spring-driven JTA transactions, make
* sure to either use the {@link #setJtaTransactionManager} method or to set the * sure to either use the {@link #setJtaTransactionManager} method or to set the

View File

@ -599,7 +599,7 @@ public interface HibernateOperations {
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors * @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#createQuery * @see org.hibernate.Session#createQuery
*/ */
List<?> find(String queryString) throws DataAccessException; List<Object> find(String queryString) throws DataAccessException;
/** /**
* Execute an HQL query, binding one value to a "?" parameter in the * Execute an HQL query, binding one value to a "?" parameter in the

View File

@ -485,7 +485,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
* @see #prepareCriteria * @see #prepareCriteria
*/ */
protected Session createSessionProxy(Session session) { protected Session createSessionProxy(Session session) {
Class<?>[] sessionIfcs = null; Class<?>[] sessionIfcs;
Class<?> mainIfc = (session instanceof org.hibernate.classic.Session ? Class<?> mainIfc = (session instanceof org.hibernate.classic.Session ?
org.hibernate.classic.Session.class : Session.class); org.hibernate.classic.Session.class : Session.class);
if (session instanceof EventSource) { if (session instanceof EventSource) {
@ -518,7 +518,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
return executeWithNativeSession(new HibernateCallback<T>() { return executeWithNativeSession(new HibernateCallback<T>() {
@Override @Override
@SuppressWarnings({ "unchecked" }) @SuppressWarnings("unchecked")
public T doInHibernate(Session session) throws HibernateException { public T doInHibernate(Session session) throws HibernateException {
if (lockMode != null) { if (lockMode != null) {
return (T) session.get(entityClass, id, lockMode); return (T) session.get(entityClass, id, lockMode);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -246,7 +246,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* resources are specified locally via this bean. * resources are specified locally via this bean.
* @see org.hibernate.cfg.Configuration#configure(java.net.URL) * @see org.hibernate.cfg.Configuration#configure(java.net.URL)
*/ */
public void setConfigLocations(Resource[] configLocations) { public void setConfigLocations(Resource... configLocations) {
this.configLocations = configLocations; this.configLocations = configLocations;
} }
@ -260,7 +260,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* @see #setMappingLocations * @see #setMappingLocations
* @see org.hibernate.cfg.Configuration#addResource * @see org.hibernate.cfg.Configuration#addResource
*/ */
public void setMappingResources(String[] mappingResources) { public void setMappingResources(String... mappingResources) {
this.mappingResources = mappingResources; this.mappingResources = mappingResources;
} }
@ -273,7 +273,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* or to specify all mappings locally. * or to specify all mappings locally.
* @see org.hibernate.cfg.Configuration#addInputStream * @see org.hibernate.cfg.Configuration#addInputStream
*/ */
public void setMappingLocations(Resource[] mappingLocations) { public void setMappingLocations(Resource... mappingLocations) {
this.mappingLocations = mappingLocations; this.mappingLocations = mappingLocations;
} }
@ -286,7 +286,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* or to specify all mappings locally. * or to specify all mappings locally.
* @see org.hibernate.cfg.Configuration#addCacheableFile(java.io.File) * @see org.hibernate.cfg.Configuration#addCacheableFile(java.io.File)
*/ */
public void setCacheableMappingLocations(Resource[] cacheableMappingLocations) { public void setCacheableMappingLocations(Resource... cacheableMappingLocations) {
this.cacheableMappingLocations = cacheableMappingLocations; this.cacheableMappingLocations = cacheableMappingLocations;
} }
@ -297,7 +297,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* or to specify all mappings locally. * or to specify all mappings locally.
* @see org.hibernate.cfg.Configuration#addJar(java.io.File) * @see org.hibernate.cfg.Configuration#addJar(java.io.File)
*/ */
public void setMappingJarLocations(Resource[] mappingJarLocations) { public void setMappingJarLocations(Resource... mappingJarLocations) {
this.mappingJarLocations = mappingJarLocations; this.mappingJarLocations = mappingJarLocations;
} }
@ -308,7 +308,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* or to specify all mappings locally. * or to specify all mappings locally.
* @see org.hibernate.cfg.Configuration#addDirectory(java.io.File) * @see org.hibernate.cfg.Configuration#addDirectory(java.io.File)
*/ */
public void setMappingDirectoryLocations(Resource[] mappingDirectoryLocations) { public void setMappingDirectoryLocations(Resource... mappingDirectoryLocations) {
this.mappingDirectoryLocations = mappingDirectoryLocations; this.mappingDirectoryLocations = mappingDirectoryLocations;
} }
@ -408,7 +408,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* @see TypeDefinitionBean * @see TypeDefinitionBean
* @see org.hibernate.cfg.Mappings#addTypeDef(String, String, java.util.Properties) * @see org.hibernate.cfg.Mappings#addTypeDef(String, String, java.util.Properties)
*/ */
public void setTypeDefinitions(TypeDefinitionBean[] typeDefinitions) { public void setTypeDefinitions(TypeDefinitionBean... typeDefinitions) {
this.typeDefinitions = typeDefinitions; this.typeDefinitions = typeDefinitions;
} }
@ -422,7 +422,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
* @see FilterDefinitionFactoryBean * @see FilterDefinitionFactoryBean
* @see org.hibernate.cfg.Configuration#addFilterDefinition * @see org.hibernate.cfg.Configuration#addFilterDefinition
*/ */
public void setFilterDefinitions(FilterDefinition[] filterDefinitions) { public void setFilterDefinitions(FilterDefinition... filterDefinitions) {
this.filterDefinitions = filterDefinitions; this.filterDefinitions = filterDefinitions;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -99,19 +99,19 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
/** /**
* Specify annotated classes, for which mappings will be read from * Specify annotated classes, for which mappings will be read from
* class-level JDK 1.5+ annotation metadata. * class-level annotation metadata.
* @see org.hibernate.cfg.Configuration#addAnnotatedClass(Class) * @see org.hibernate.cfg.Configuration#addAnnotatedClass(Class)
*/ */
public void setAnnotatedClasses(Class<?>[] annotatedClasses) { public void setAnnotatedClasses(Class<?>... annotatedClasses) {
this.annotatedClasses = annotatedClasses; this.annotatedClasses = annotatedClasses;
} }
/** /**
* Specify the names of annotated packages, for which package-level * Specify the names of annotated packages, for which package-level
* JDK 1.5+ annotation metadata will be read. * annotation metadata will be read.
* @see org.hibernate.cfg.Configuration#addPackage(String) * @see org.hibernate.cfg.Configuration#addPackage(String)
*/ */
public void setAnnotatedPackages(String[] annotatedPackages) { public void setAnnotatedPackages(String... annotatedPackages) {
this.annotatedPackages = annotatedPackages; this.annotatedPackages = annotatedPackages;
} }
@ -122,7 +122,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
* classes in the classpath. This is analogous to Spring's component-scan feature * classes in the classpath. This is analogous to Spring's component-scan feature
* ({@link org.springframework.context.annotation.ClassPathBeanDefinitionScanner}). * ({@link org.springframework.context.annotation.ClassPathBeanDefinitionScanner}).
*/ */
public void setPackagesToScan(String[] packagesToScan) { public void setPackagesToScan(String... packagesToScan) {
this.packagesToScan = packagesToScan; this.packagesToScan = packagesToScan;
} }
@ -134,7 +134,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
* Hibernate's special {@code @org.hibernate.annotations.Entity}. * Hibernate's special {@code @org.hibernate.annotations.Entity}.
* @see #setPackagesToScan * @see #setPackagesToScan
*/ */
public void setEntityTypeFilters(TypeFilter[] entityTypeFilters) { public void setEntityTypeFilters(TypeFilter... entityTypeFilters) {
this.entityTypeFilters = entityTypeFilters; this.entityTypeFilters = entityTypeFilters;
} }