diff --git a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java index 6085292c02..a65168f93f 100644 --- a/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java +++ b/tooling/metamodel-generator/src/jakartaData/java/org/hibernate/processor/test/data/eg/Library.java @@ -14,10 +14,12 @@ import jakarta.data.repository.Query; import jakarta.data.repository.Repository; import jakarta.data.repository.Save; import jakarta.data.repository.Update; +import jakarta.transaction.Transactional; import java.time.LocalDate; import java.util.List; +@Transactional @Repository public interface Library { diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/ClassWriter.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/ClassWriter.java index 1a6a8fd0b0..b770e1c34e 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/ClassWriter.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/ClassWriter.java @@ -94,6 +94,7 @@ public final class ClassWriter { if ( context.addSuppressWarningsAnnotation() ) { pw.println( writeSuppressWarnings() ); } + entity.inheritedAnnotations().forEach(pw::println); printClassDeclaration( entity, pw ); diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java index 98f95a1ca4..63d688bc66 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java @@ -2698,4 +2698,17 @@ public class AnnotationMetaEntity extends AnnotationMeta { + "' of inherited member '" + element.getEnclosingElement().getSimpleName() + "'" : message + " for inherited member '" + element.getSimpleName() + "'"; } + + @Override + public List inheritedAnnotations() { + if ( jakartaDataRepository ) { + return element.getAnnotationMirrors().stream() + .filter(annotationMirror -> hasAnnotation(annotationMirror.getAnnotationType().asElement(), + "jakarta.interceptor.InterceptorBinding")) + .collect(toList()); + } + else { + return emptyList(); + } + } } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaPackage.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaPackage.java index b679882152..07a2da3b27 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaPackage.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaPackage.java @@ -12,6 +12,7 @@ import org.hibernate.processor.ImportContextImpl; import org.hibernate.processor.model.ImportContext; import org.hibernate.processor.model.MetaAttribute; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.PackageElement; import javax.tools.Diagnostic; import java.util.ArrayList; @@ -19,6 +20,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static java.util.Collections.emptyList; + /** * Class used to collect meta information about an annotated package. * @@ -164,4 +167,9 @@ public class AnnotationMetaPackage extends AnnotationMeta { public boolean isJakartaDataStyle() { return false; } + + @Override + public List inheritedAnnotations() { + return emptyList(); + } } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/model/Metamodel.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/model/Metamodel.java index c01a68dd06..9c230172ef 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/model/Metamodel.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/model/Metamodel.java @@ -10,6 +10,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.hibernate.processor.Context; import java.util.List; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; /** @@ -45,4 +46,6 @@ public interface Metamodel extends ImportContext { String scope(); boolean isJakartaDataStyle(); + + List inheritedAnnotations(); } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/xml/XmlMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/xml/XmlMetaEntity.java index 019043de00..452f1f424e 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/xml/XmlMetaEntity.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/xml/XmlMetaEntity.java @@ -8,6 +8,7 @@ package org.hibernate.processor.xml; import java.util.ArrayList; import java.util.List; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -46,6 +47,7 @@ import org.hibernate.processor.xml.jaxb.OneToOne; import org.checkerframework.checker.nullness.qual.Nullable; +import static java.util.Collections.emptyList; import static org.hibernate.processor.util.StringUtil.determineFullyQualifiedClassName; import static org.hibernate.processor.util.TypeUtils.extractClosestRealTypeAsString; import static org.hibernate.processor.util.TypeUtils.findMappedSuperClass; @@ -644,4 +646,9 @@ public class XmlMetaEntity implements Metamodel { public boolean isJakartaDataStyle() { return false; } + + @Override + public List inheritedAnnotations() { + return emptyList(); + } }