From 24df225d80439330d795fc05e63e3b9bb38278e7 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Fri, 20 Dec 2024 20:00:41 +0100 Subject: [PATCH] fixes for UPDATE queries --- .../annotation/AbstractAnnotatedMethod.java | 2 +- .../processor/annotation/QueryMethod.java | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractAnnotatedMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractAnnotatedMethod.java index be3ffcf122dc..fe3f49abb3d2 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractAnnotatedMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractAnnotatedMethod.java @@ -94,7 +94,7 @@ protected void handle(StringBuilder declaration, String handled, String rethrown declaration.append( "\n\t\t\t.onFailure(" ) .append( annotationMetaEntity.importType( handled ) ) .append( ".class)\n" ) - .append( "\t\t\t\t\t.transform((_ex) -> new " ) + .append( "\t\t\t\t\t.transform(_ex -> new " ) .append( annotationMetaEntity.importType( rethrown ) ) .append( "(_ex.getMessage(), _ex))" ); diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/QueryMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/QueryMethod.java index 6458c826365a..a624225fcce6 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/QueryMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/QueryMethod.java @@ -80,7 +80,7 @@ boolean isNullable(int index) { @Override boolean singleResult() { - return containerType == null; + return containerType == null && !isUpdate; } @Override @@ -150,11 +150,22 @@ && isUsingEntityManager() ) { private void execute(StringBuilder declaration, boolean unwrapped) { if ( isUpdate ) { declaration - .append("\t\t\t") - .append(".executeUpdate()"); - if ( "boolean".equals(returnTypeName) ) { - declaration - .append(" > 0"); + .append("\t\t\t.executeUpdate()"); + if ( isReactive() ) { + if ( Void.class.getName().equals( returnTypeName ) ) { + declaration + .append( "\n\t\t\t.replaceWithVoid()" ); + } + else if ( Boolean.class.getName().equals( returnTypeName ) ) { + declaration + .append( "\n\t\t\t.map(rows -> rows>0)" ); + } + } + else { + if ( "boolean".equals( returnTypeName ) ) { + declaration + .append( " > 0" ); + } } } else {