diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java index 5b380dd43c..12ec1628c2 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java @@ -279,14 +279,14 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod { .append(" exception) {\n") .append("\t\tthrow new ") .append(annotationMetaEntity.importType("jakarta.data.exceptions.EmptyResultException")) - .append("(exception);\n") + .append("(exception.getMessage(), exception);\n") .append("\t}\n") .append("\tcatch (") .append(annotationMetaEntity.importType("jakarta.persistence.NonUniqueResultException")) .append(" exception) {\n") .append("\t\tthrow new ") .append(annotationMetaEntity.importType("jakarta.data.exceptions.NonUniqueResultException")) - .append("(exception);\n") + .append("(exception.getMessage(), exception);\n") .append("\t}\n"); } declaration @@ -295,7 +295,7 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod { .append(" exception) {\n") .append("\t\tthrow new ") .append(annotationMetaEntity.importType("jakarta.data.exceptions.DataException")) - .append("(exception);\n") + .append("(exception.getMessage(), exception);\n") .append("\t}\n"); } } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/IdFinderMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/IdFinderMethod.java index e192d35f58..d926c1ae1a 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/IdFinderMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/IdFinderMethod.java @@ -86,7 +86,11 @@ public class IdFinderMethod extends AbstractFinderMethod { declaration .append("\t\tif (_result == null) throw new ") .append(annotationMetaEntity.importType("jakarta.data.exceptions.EmptyResultException")) - .append("(new ") + .append("(\"No '") + .append(annotationMetaEntity.importType(entity)) + .append("' for given id [\" + ") + .append(paramName) + .append(" + \"]\",\n\t\t\t\tnew ") .append(annotationMetaEntity.importType("org.hibernate.ObjectNotFoundException")) .append("((Object) ") .append(paramName) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/LifecycleMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/LifecycleMethod.java index ba9fd0e073..8ed0db96d2 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/LifecycleMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/LifecycleMethod.java @@ -192,7 +192,7 @@ public class LifecycleMethod extends AbstractAnnotatedMethod { .append(" exception) {\n") .append("\t\tthrow new ") .append(annotationMetaEntity.importType(convertedException)) - .append("(exception);\n") + .append("(exception.getMessage(), exception);\n") .append("\t}\n"); }