diff --git a/pom.xml b/pom.xml index 2b2d611df..ef7d75497 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 3.0.0-SNAPSHOT 1.9.2 2.9.0 - 5.6.9.Final + 6.1.1.Final 2.0.0 2.0.1 3.0.0 diff --git a/spring-batch-infrastructure/pom.xml b/spring-batch-infrastructure/pom.xml index b00d0db1a..3508316cc 100644 --- a/spring-batch-infrastructure/pom.xml +++ b/spring-batch-infrastructure/pom.xml @@ -96,9 +96,9 @@ true - org.hibernate - hibernate-core-jakarta - ${hibernate-core-jakarta.version} + org.hibernate.orm + hibernate-core + ${hibernate-core.version} true diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java index b78f89984..ca1743600 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2022 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. @@ -52,6 +52,7 @@ import org.springframework.util.ClassUtils; * * @author Robert Kasanicky * @author Dave Syer + * @author Mahmoud Ben Hassine */ public class HibernateCursorItemReader extends AbstractItemCountingItemStreamItemReader implements InitializingBean { @@ -62,7 +63,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream setName(ClassUtils.getShortName(HibernateCursorItemReader.class)); } - private ScrollableResults cursor; + private ScrollableResults cursor; private boolean initialized = false; @@ -143,25 +144,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream @Override protected T doRead() throws Exception { if (cursor.next()) { - Object[] data = cursor.get(); - - if (data.length > 1) { - // If there are multiple items this must be a projection - // and T is an array type. - @SuppressWarnings("unchecked") - T item = (T) data; - return item; - } - else { - // Assume if there is only one item that it is the data the user - // wants. - // If there is only one item this is going to be a nasty shock - // if T is an array type but there's not much else we can do... - @SuppressWarnings("unchecked") - T item = (T) data[0]; - return item; - } - + return cursor.get(); } return null; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java index 1a923328f..444bbaef1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java @@ -111,7 +111,7 @@ public class HibernateItemReaderHelper implements InitializingBean { * @param parameterValues the parameter values to use (or null if none). * @return a forward-only {@link ScrollableResults} */ - public ScrollableResults getForwardOnlyCursor(int fetchSize, Map parameterValues) { + public ScrollableResults getForwardOnlyCursor(int fetchSize, Map parameterValues) { Query query = createQuery(); if (!CollectionUtils.isEmpty(parameterValues)) { query.setProperties(parameterValues); @@ -123,7 +123,6 @@ public class HibernateItemReaderHelper implements InitializingBean { * Open appropriate type of hibernate session and create the query. * @return a Hibernate Query */ - @SuppressWarnings("unchecked") // Hibernate APIs do not use a typed Query public Query createQuery() { if (useStatelessSession) { diff --git a/spring-batch-samples/pom.xml b/spring-batch-samples/pom.xml index 9ba7e52b8..40957133e 100644 --- a/spring-batch-samples/pom.xml +++ b/spring-batch-samples/pom.xml @@ -72,9 +72,9 @@ ${aspectj.version} - org.hibernate - hibernate-core-jakarta - ${hibernate-core-jakarta.version} + org.hibernate.orm + hibernate-core + ${hibernate-core.version} org.apache.commons