Skip to content

Commit

Permalink
Upgrade to Hibernate 6.3.1; Cleanup in JPA module
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan committed Oct 12, 2023
1 parent ea3e118 commit 7169215
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -314,7 +314,6 @@ private void setParametersIfRequired(String queryString, @Nullable ParameterSour
final Object paramValue;

if (position != null) {

if (source instanceof PositionSupportingParameterSource) {
paramValue = ((PositionSupportingParameterSource) source).getValueByPosition(position);
query.setParameter(position, paramValue);
Expand All @@ -323,10 +322,8 @@ private void setParametersIfRequired(String queryString, @Nullable ParameterSour
throw new JpaOperationFailedException("Positional Parameters are only support "
+ "for PositionSupportingParameterSources.", queryString);
}

}
else {

if (StringUtils.hasText(paramName)) {
paramValue = source.getValue(paramName);
query.setParameter(paramName, paramValue);
Expand All @@ -337,13 +334,11 @@ private void setParametersIfRequired(String queryString, @Nullable ParameterSour
"Additionally it is not a positional parameter, neither.", queryString);
}
}

}
}
else {
throw new IllegalArgumentException("Query has parameters but no parameter source provided");
}

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -300,7 +300,6 @@ public void setParameterSource(ParameterSource parameterSource) {
}

/**
*
* 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
Expand Down Expand Up @@ -373,7 +372,6 @@ public void afterPropertiesSet() {
new ExpressionEvaluatingParameterSourceFactory(this.beanFactory);
expressionSourceFactory.setParameters(this.jpaParameters);
this.parameterSourceFactory = expressionSourceFactory;

}
else {
throw new IllegalStateException("The 'jpaParameters' and 'parameterSourceFactory' " +
Expand All @@ -384,14 +382,11 @@ public void afterPropertiesSet() {
if (this.usePayloadAsParameterSource == null) {
this.usePayloadAsParameterSource = false;
}

}
else {

if (this.parameterSourceFactory == null) {
this.parameterSourceFactory = new BeanPropertyParameterSourceFactory();
}

if (this.usePayloadAsParameterSource == null) {
this.usePayloadAsParameterSource = true;
}
Expand Down Expand Up @@ -441,12 +436,14 @@ else if (this.namedQuery != null) {
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);
}
Expand All @@ -457,8 +454,8 @@ private Object executeOutboundJpaOperationOnPersistentMode(Message<?> message) {
this.jpaOperations.flush();
}
return payload;
default:
throw new IllegalStateException("Unsupported PersistMode: " + this.persistMode.name());
}
default -> throw new IllegalStateException("Unsupported PersistMode: " + this.persistMode.name());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -33,7 +33,7 @@
* 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.
*
Expand Down Expand Up @@ -65,12 +65,7 @@ public JpaOutboundGateway(JpaExecutor jpaExecutor) {

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setProducesReply(boolean producesReply) {
}

/**
* 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
Expand Down

0 comments on commit 7169215

Please sign in to comment.