Polishing

This commit is contained in:
Juergen Hoeller
2014-01-27 22:49:14 +01:00
parent b4115f3202
commit 398f91cb74
4 changed files with 16 additions and 7 deletions

View File

@@ -43,10 +43,14 @@ import org.springframework.core.io.support.ResourcePatternUtils;
* Hibernate SessionFactory in a Spring application context; the SessionFactory can
* 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.
* It 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 annotation scanning.
* <p><b>This variant of LocalSessionFactoryBean requires Hibernate 4.0 or higher.</b>
* Note that this version is not compatible with the (the quite refactored) Hibernate
* 4.3 yet; please upgrade to the Spring 4.0 line for full Hibernate 4.3 support.
* We recommend using this version with the latest Hibernate 4.1.x or 4.2.x releases.
*
* <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
* 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");
* you may not use this file except in compliance with the License.
@@ -54,6 +54,11 @@ import org.springframework.util.ClassUtils;
* <p>This is designed for programmatic use, e.g. in {@code @Bean} factory methods.
* Consider using {@link LocalSessionFactoryBean} for XML bean definition files.
*
* <p><b>Requires Hibernate 4.0 or higher.</b> Note that this version is not
* compatible with the (the quite refactored) Hibernate 4.3 yet; please upgrade
* to the Spring 4.0 line for full Hibernate 4.3 support. We recommend using
* this version with the latest Hibernate 4.1.x or 4.2.x releases.
*
* <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
* "hibernate.transaction.factory_class" property to {@link CMTTransactionFactory}.

View File

@@ -1001,7 +1001,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
final String queryName, final String[] paramNames, final Object[] values)
throws DataAccessException {
if (paramNames != null && values != null && paramNames.length != values.length) {
if (values != null && (paramNames == null || paramNames.length != values.length)) {
throw new IllegalArgumentException("Length of paramNames array must match length of values array");
}
return executeWithNativeSession(new HibernateCallback<List>() {

View File

@@ -165,7 +165,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
protected void postProcessMappings(Configuration config) throws HibernateException {
AnnotationConfiguration annConfig = (AnnotationConfiguration) config;
if (this.annotatedClasses != null) {
for (Class annotatedClass : this.annotatedClasses) {
for (Class<?> annotatedClass : this.annotatedClasses) {
annConfig.addAnnotatedClass(annotatedClass);
}
}