Upgrade Hibernate to version 6.1.1.Final

This commit is contained in:
Mahmoud Ben Hassine
2022-07-13 18:42:39 +02:00
parent b89ea8e789
commit 5a69b6b28b
5 changed files with 12 additions and 30 deletions

View File

@@ -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<T> extends AbstractItemCountingItemStreamItemReader<T>
implements InitializingBean {
@@ -62,7 +63,7 @@ public class HibernateCursorItemReader<T> extends AbstractItemCountingItemStream
setName(ClassUtils.getShortName(HibernateCursorItemReader.class));
}
private ScrollableResults cursor;
private ScrollableResults<? extends T> cursor;
private boolean initialized = false;
@@ -143,25 +144,7 @@ public class HibernateCursorItemReader<T> 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;
}

View File

@@ -111,7 +111,7 @@ public class HibernateItemReaderHelper<T> 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<String, Object> parameterValues) {
public ScrollableResults<? extends T> getForwardOnlyCursor(int fetchSize, Map<String, Object> parameterValues) {
Query<? extends T> query = createQuery();
if (!CollectionUtils.isEmpty(parameterValues)) {
query.setProperties(parameterValues);
@@ -123,7 +123,6 @@ public class HibernateItemReaderHelper<T> 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<? extends T> createQuery() {
if (useStatelessSession) {