Skip to content

Commit 212b3ce

Browse files
ces518fmbenhassine
authored andcommitted
change parameterValues check -> CollectionUtils.isEmpty
Resolves #4021
1 parent 875be70 commit 212b3ce

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-2021 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.
@@ -28,6 +28,7 @@
2828
import org.springframework.batch.item.database.orm.HibernateQueryProvider;
2929
import org.springframework.beans.factory.InitializingBean;
3030
import org.springframework.util.Assert;
31+
import org.springframework.util.CollectionUtils;
3132
import org.springframework.util.StringUtils;
3233

3334
/**
@@ -36,7 +37,7 @@
3637
*
3738
* @author Dave Syer
3839
* @author Mahmoud Ben Hassine
39-
*
40+
* @author June Young. Park
4041
*/
4142
public class HibernateItemReaderHelper<T> implements InitializingBean {
4243

@@ -84,7 +85,7 @@ public void setQueryProvider(HibernateQueryProvider<? extends T> queryProvider)
8485
*/
8586
public void setUseStatelessSession(boolean useStatelessSession) {
8687
Assert.state(statefulSession == null && statelessSession == null,
87-
"The useStatelessSession flag can only be set before a session is initialized.");
88+
"The useStatelessSession flag can only be set before a session is initialized.");
8889
this.useStatelessSession = useStatelessSession;
8990
}
9091

@@ -103,7 +104,7 @@ public void afterPropertiesSet() throws Exception {
103104
if (queryProvider == null) {
104105
Assert.notNull(sessionFactory, "session factory must be set");
105106
Assert.state(StringUtils.hasText(queryString) ^ StringUtils.hasText(queryName),
106-
"queryString or queryName must be set");
107+
"queryString or queryName must be set");
107108
}
108109
}
109110

@@ -117,7 +118,7 @@ public void afterPropertiesSet() throws Exception {
117118
*/
118119
public ScrollableResults getForwardOnlyCursor(int fetchSize, Map<String, Object> parameterValues) {
119120
Query<? extends T> query = createQuery();
120-
if (parameterValues != null) {
121+
if (!CollectionUtils.isEmpty(parameterValues)) {
121122
query.setProperties(parameterValues);
122123
}
123124
return query.setFetchSize(fetchSize).scroll(ScrollMode.FORWARD_ONLY);
@@ -215,7 +216,7 @@ public Collection<? extends T> readPage(int page, int pageSize, int fetchSize, M
215216
clear();
216217

217218
Query<? extends T> query = createQuery();
218-
if (parameterValues != null) {
219+
if (!CollectionUtils.isEmpty(parameterValues)) {
219220
query.setProperties(parameterValues);
220221
}
221222
return query.setFetchSize(fetchSize).setFirstResult(page * pageSize).setMaxResults(pageSize).list();

0 commit comments

Comments
 (0)