Skip to content

Commit cf626df

Browse files
committed
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
1 parent c517833 commit cf626df

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMeta.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,20 @@ private void addAuxiliaryMembersForAnnotation(String annotationName, String pref
187187
}
188188

189189
private void addAuxiliaryMembersForMirror(AnnotationMirror mirror, String prefix) {
190-
mirror.getElementValues().forEach((key, value) -> {
191-
if ( key.getSimpleName().contentEquals("name") ) {
192-
final String name = value.getValue().toString();
193-
if ( !name.isEmpty() ) {
194-
putMember( prefix + name, auxiliaryMember( mirror, prefix, name ) );
190+
if ( !isJakartaDataStyle() ) {
191+
mirror.getElementValues().forEach((key, value) -> {
192+
if ( key.getSimpleName().contentEquals("name") ) {
193+
final String name = value.getValue().toString();
194+
if ( !name.isEmpty() ) {
195+
putMember( prefix + name, auxiliaryMember( mirror, prefix, name ) );
196+
}
195197
}
196-
}
197-
});
198+
});
199+
}
198200
}
199201

200202
private NameMetaAttribute auxiliaryMember(AnnotationMirror mirror, String prefix, String name) {
201-
if ( !isJakartaDataStyle() && "QUERY_".equals(prefix) ) {
203+
if ( "QUERY_".equals(prefix) ) {
202204
final AnnotationValue resultClass = getAnnotationValue( mirror, "resultClass" );
203205
// if there is no explicit result class, we will infer it later by
204206
// type checking the query (this is allowed but not required by JPA)
@@ -207,7 +209,7 @@ private NameMetaAttribute auxiliaryMember(AnnotationMirror mirror, String prefix
207209
resultClass == null ? JAVA_OBJECT : resultClass.getValue().toString(),
208210
"jakarta.persistence.TypedQueryReference", null );
209211
}
210-
else if ( !isJakartaDataStyle() && "GRAPH_".equals(prefix) ) {
212+
else if ( "GRAPH_".equals(prefix) ) {
211213
return new TypedMetaAttribute( this, name, prefix, getQualifiedName(),
212214
"jakarta.persistence.EntityGraph", null );
213215
}

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/NameMetaAttribute.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ public String getAttributeDeclarationString() {
4040

4141
@Override
4242
public String getAttributeNameDeclarationString() {
43-
return new StringBuilder()
44-
.append("public static final ")
43+
final StringBuilder declaration = new StringBuilder();
44+
if ( !annotationMetaEntity.isJakartaDataStyle() ) {
45+
declaration.append( "public static final " );
46+
}
47+
return declaration
4548
.append(annotationMetaEntity.importType(String.class.getName()))
4649
.append(' ')
4750
.append(prefix)

0 commit comments

Comments
 (0)