diff --git a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBean.java b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBean.java index 3f9096d605..b29682f3ba 100644 --- a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBean.java +++ b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBean.java @@ -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. * - *
NOTE: 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. + *
This variant of LocalSessionFactoryBean requires Hibernate 4.0 or higher. + * 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. + * + *
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. * *
NOTE: To set up Hibernate 4 for Spring-driven JTA transactions, make * sure to either specify the {@link #setJtaTransactionManager "jtaTransactionManager"} diff --git a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java index b0aac2d2bb..3122cd30ec 100644 --- a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java +++ b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java @@ -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; *
This is designed for programmatic use, e.g. in {@code @Bean} factory methods. * Consider using {@link LocalSessionFactoryBean} for XML bean definition files. * + *
Requires Hibernate 4.0 or higher. 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. + * *
NOTE: 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}.
diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTemplate.java b/spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTemplate.java
index c656fe694f..dc947b2cb6 100644
--- a/spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTemplate.java
+++ b/spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTemplate.java
@@ -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() {
diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.java
index ab2d1d460c..8366a5f2eb 100644
--- a/spring-orm/src/main/java/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.java
+++ b/spring-orm/src/main/java/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.java
@@ -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);
}
}