Updated HibernateItemReaderHelper to use reflection for Session#close()
Hibernate 5 changed the signature of the Session#close() method from returning a Connection to being void. To support both verions, we've moved to making the call via reflection. This commit also upgrades the ActiveMQ version used in testing to be compliant with the Spring IO Platform. Resolves BATCH-2496
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,6 +29,7 @@ import org.hibernate.StatelessSession;
|
||||
import org.springframework.batch.item.database.orm.HibernateQueryProvider;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -197,7 +199,9 @@ public class HibernateItemReaderHelper<T> implements InitializingBean {
|
||||
statelessSession = null;
|
||||
}
|
||||
if (statefulSession != null) {
|
||||
statefulSession.close();
|
||||
|
||||
Method close = ReflectionUtils.findMethod(Session.class, "close");
|
||||
ReflectionUtils.invokeMethod(close, statefulSession);
|
||||
statefulSession = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user