don't generate "auxiliary" members for Jakarta Data static metamodel

since it doesn't seem like these are very usueful with the repository
programming model
This commit is contained in:
Gavin King 2024-10-02 16:35:46 +02:00
parent c517833758
commit cf626df3db
2 changed files with 16 additions and 11 deletions

View File

@ -187,6 +187,7 @@ public abstract class AnnotationMeta implements Metamodel {
}
private void addAuxiliaryMembersForMirror(AnnotationMirror mirror, String prefix) {
if ( !isJakartaDataStyle() ) {
mirror.getElementValues().forEach((key, value) -> {
if ( key.getSimpleName().contentEquals("name") ) {
final String name = value.getValue().toString();
@ -196,9 +197,10 @@ public abstract class AnnotationMeta implements Metamodel {
}
});
}
}
private NameMetaAttribute auxiliaryMember(AnnotationMirror mirror, String prefix, String name) {
if ( !isJakartaDataStyle() && "QUERY_".equals(prefix) ) {
if ( "QUERY_".equals(prefix) ) {
final AnnotationValue resultClass = getAnnotationValue( mirror, "resultClass" );
// if there is no explicit result class, we will infer it later by
// type checking the query (this is allowed but not required by JPA)
@ -207,7 +209,7 @@ public abstract class AnnotationMeta implements Metamodel {
resultClass == null ? JAVA_OBJECT : resultClass.getValue().toString(),
"jakarta.persistence.TypedQueryReference", null );
}
else if ( !isJakartaDataStyle() && "GRAPH_".equals(prefix) ) {
else if ( "GRAPH_".equals(prefix) ) {
return new TypedMetaAttribute( this, name, prefix, getQualifiedName(),
"jakarta.persistence.EntityGraph", null );
}

View File

@ -40,8 +40,11 @@ class NameMetaAttribute implements MetaAttribute {
@Override
public String getAttributeNameDeclarationString() {
return new StringBuilder()
.append("public static final ")
final StringBuilder declaration = new StringBuilder();
if ( !annotationMetaEntity.isJakartaDataStyle() ) {
declaration.append( "public static final " );
}
return declaration
.append(annotationMetaEntity.importType(String.class.getName()))
.append(' ')
.append(prefix)