Skip to content

Collection's empty data check using CollectionUtils.isEmpty #4022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.batch.item.database.orm.HibernateQueryProvider;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

/**
Expand All @@ -36,7 +37,7 @@
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
* @author June Young. Park
*/
public class HibernateItemReaderHelper<T> implements InitializingBean {

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

Expand All @@ -103,7 +104,7 @@ public void afterPropertiesSet() throws Exception {
if (queryProvider == null) {
Assert.notNull(sessionFactory, "session factory must be set");
Assert.state(StringUtils.hasText(queryString) ^ StringUtils.hasText(queryName),
"queryString or queryName must be set");
"queryString or queryName must be set");
}
}

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

Query<? extends T> query = createQuery();
if (parameterValues != null) {
if (!CollectionUtils.isEmpty(parameterValues)) {
query.setProperties(parameterValues);
}
return query.setFetchSize(fetchSize).setFirstResult(page * pageSize).setMaxResults(pageSize).list();
Expand Down