Upgrade to Hibernate 6.3.1; Cleanup in JPA module

This commit is contained in:
Artem Bilan
2023-10-12 16:32:52 -04:00
parent ea3e118c8c
commit 7169215768
5 changed files with 14 additions and 27 deletions

View File

@@ -70,7 +70,7 @@ ext {
groovyVersion = '4.0.15'
hamcrestVersion = '2.2'
hazelcastVersion = '5.3.2'
hibernateVersion = '6.2.8.Final'
hibernateVersion = '6.3.1.Final'
hsqldbVersion = '2.7.2'
h2Version = '2.2.224'
jacksonVersion = '2.15.2'

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@@ -314,7 +314,6 @@ public class DefaultJpaOperations extends AbstractJpaOperations {
final Object paramValue;
if (position != null) {
if (source instanceof PositionSupportingParameterSource) {
paramValue = ((PositionSupportingParameterSource) source).getValueByPosition(position);
query.setParameter(position, paramValue);
@@ -323,10 +322,8 @@ public class DefaultJpaOperations extends AbstractJpaOperations {
throw new JpaOperationFailedException("Positional Parameters are only support "
+ "for PositionSupportingParameterSources.", queryString);
}
}
else {
if (StringUtils.hasText(paramName)) {
paramValue = source.getValue(paramName);
query.setParameter(paramName, paramValue);
@@ -337,13 +334,11 @@ public class DefaultJpaOperations extends AbstractJpaOperations {
"Additionally it is not a positional parameter, neither.", queryString);
}
}
}
}
else {
throw new IllegalArgumentException("Query has parameters but no parameter source provided");
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -300,7 +300,6 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
}
/**
*
* This parameter indicates that only one result object shall be returned as
* a result from the executed JPA operation. If set to <code>true</code> and
* the result list from the JPA operations contains only 1 element, then that
@@ -373,7 +372,6 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
new ExpressionEvaluatingParameterSourceFactory(this.beanFactory);
expressionSourceFactory.setParameters(this.jpaParameters);
this.parameterSourceFactory = expressionSourceFactory;
}
else {
throw new IllegalStateException("The 'jpaParameters' and 'parameterSourceFactory' " +
@@ -384,14 +382,11 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
if (this.usePayloadAsParameterSource == null) {
this.usePayloadAsParameterSource = false;
}
}
else {
if (this.parameterSourceFactory == null) {
this.parameterSourceFactory = new BeanPropertyParameterSourceFactory();
}
if (this.usePayloadAsParameterSource == null) {
this.usePayloadAsParameterSource = true;
}
@@ -441,12 +436,14 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
private Object executeOutboundJpaOperationOnPersistentMode(Message<?> message) {
Object payload = message.getPayload();
switch (this.persistMode) {
case PERSIST:
case PERSIST -> {
this.jpaOperations.persist(payload, this.flushSize, this.clearOnFlush);
return payload;
case MERGE:
}
case MERGE -> {
return this.jpaOperations.merge(payload, this.flushSize, this.clearOnFlush); // NOSONAR
case DELETE:
}
case DELETE -> {
if (payload instanceof Iterable) {
this.jpaOperations.deleteInBatch((Iterable<?>) payload);
}
@@ -457,8 +454,8 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
this.jpaOperations.flush();
}
return payload;
default:
throw new IllegalStateException("Unsupported PersistMode: " + this.persistMode.name());
}
default -> throw new IllegalStateException("Unsupported PersistMode: " + this.persistMode.name());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
* Depending on the selected {@link OutboundGatewayType}, the outbound gateway
* will use either the {@link JpaExecutor}'s poll method or its
* executeOutboundJpaOperation method.
*
* <p>
* In order to initialize the adapter, you must provide a {@link JpaExecutor} as
* constructor.
*
@@ -65,12 +65,7 @@ public class JpaOutboundGateway extends AbstractReplyProducingMessageHandler {
@Override
public String getComponentType() {
return "jpa:outbound-gateway";
}
@Override
protected void doInit() {
this.jpaExecutor.setBeanFactory(this.getBeanFactory());
return "jpa:outbound-" + (this.producesReply ? "gateway" : "channel-adapter");
}
@Override

View File

@@ -62,7 +62,7 @@ public class JpaOutboundGatewayFactoryBean extends AbstractSimpleMessageHandlerF
}
/**
* Specifies the time the gateway will wait to send the result to the reply channel.
* Specify the time the gateway will wait to send the result to the reply channel.
* Only applies when the reply channel itself might block the 'send' operation
* (for example a bounded QueueChannel that is currently full).
* @param replyTimeout The timeout in milliseconds