Skip to content

Commit 721d0bb

Browse files
ces518fmbenhassine
authored andcommitted
change parameterValues check -> CollectionUtils.isEmpty
Resolves #4021
1 parent 01a80f8 commit 721d0bb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
import org.springframework.batch.item.database.orm.HibernateQueryProvider;
3131
import org.springframework.beans.factory.InitializingBean;
3232
import org.springframework.util.Assert;
33+
import org.springframework.util.CollectionUtils;
3334
import org.springframework.util.ReflectionUtils;
3435
import org.springframework.util.StringUtils;
3536

@@ -39,7 +40,7 @@
3940
*
4041
* @author Dave Syer
4142
* @author Mahmoud Ben Hassine
42-
*
43+
* @author June Young. Park
4344
*/
4445
@SuppressWarnings("rawtypes")
4546
public class HibernateItemReaderHelper<T> implements InitializingBean {
@@ -88,7 +89,7 @@ public void setQueryProvider(HibernateQueryProvider<? extends T> queryProvider)
8889
*/
8990
public void setUseStatelessSession(boolean useStatelessSession) {
9091
Assert.state(statefulSession == null && statelessSession == null,
91-
"The useStatelessSession flag can only be set before a session is initialized.");
92+
"The useStatelessSession flag can only be set before a session is initialized.");
9293
this.useStatelessSession = useStatelessSession;
9394
}
9495

@@ -107,7 +108,7 @@ public void afterPropertiesSet() throws Exception {
107108
if (queryProvider == null) {
108109
Assert.notNull(sessionFactory, "session factory must be set");
109110
Assert.state(StringUtils.hasText(queryString) ^ StringUtils.hasText(queryName),
110-
"queryString or queryName must be set");
111+
"queryString or queryName must be set");
111112
}
112113
}
113114

@@ -121,7 +122,7 @@ public void afterPropertiesSet() throws Exception {
121122
*/
122123
public ScrollableResults getForwardOnlyCursor(int fetchSize, Map<String, Object> parameterValues) {
123124
Query query = createQuery();
124-
if (parameterValues != null) {
125+
if (!CollectionUtils.isEmpty(parameterValues)) {
125126
query.setProperties(parameterValues);
126127
}
127128
return query.setFetchSize(fetchSize).scroll(ScrollMode.FORWARD_ONLY);
@@ -220,7 +221,7 @@ public Collection<? extends T> readPage(int page, int pageSize, int fetchSize, M
220221
clear();
221222

222223
Query query = createQuery();
223-
if (parameterValues != null) {
224+
if (!CollectionUtils.isEmpty(parameterValues)) {
224225
query.setProperties(parameterValues);
225226
}
226227
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)