HHH-18649 nice Javadoc for static TypedQueryReferences
This commit is contained in:
parent
975dfa1ed9
commit
f929a78948
|
@ -127,7 +127,7 @@ public abstract class AnnotationMeta implements Metamodel {
|
|||
if ( resultType != null ) {
|
||||
putMember( "QUERY_" + name,
|
||||
new TypedMetaAttribute( this, name, "QUERY_", resultType,
|
||||
"jakarta.persistence.TypedQueryReference" ) );
|
||||
"jakarta.persistence.TypedQueryReference", hql ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,11 +205,11 @@ public abstract class AnnotationMeta implements Metamodel {
|
|||
// and then we will replace this TypedMetaAttribute
|
||||
return new TypedMetaAttribute( this, name, prefix,
|
||||
resultClass == null ? JAVA_OBJECT : resultClass.getValue().toString(),
|
||||
"jakarta.persistence.TypedQueryReference" );
|
||||
"jakarta.persistence.TypedQueryReference", null );
|
||||
}
|
||||
else if ( !isJakartaDataStyle() && "GRAPH_".equals(prefix) ) {
|
||||
return new TypedMetaAttribute( this, name, prefix, getQualifiedName(),
|
||||
"jakarta.persistence.EntityGraph" );
|
||||
"jakarta.persistence.EntityGraph", null );
|
||||
}
|
||||
else {
|
||||
return new NameMetaAttribute( this, name, prefix);
|
||||
|
|
|
@ -4,28 +4,34 @@
|
|||
*/
|
||||
package org.hibernate.processor.annotation;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.hibernate.processor.model.Metamodel;
|
||||
|
||||
import static org.hibernate.processor.util.StringUtil.nameToMethodName;
|
||||
|
||||
/**
|
||||
* Represents a named query or named entity graph.
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
class TypedMetaAttribute extends NameMetaAttribute {
|
||||
private final String prefix;
|
||||
private final String resultType;
|
||||
private final String referenceType;
|
||||
private final @Nullable String query;
|
||||
|
||||
public TypedMetaAttribute(
|
||||
Metamodel annotationMetaEntity,
|
||||
String name,
|
||||
String prefix,
|
||||
String resultType,
|
||||
String referenceType) {
|
||||
String referenceType,
|
||||
@Nullable String query) {
|
||||
super( annotationMetaEntity, name, prefix );
|
||||
this.prefix = prefix;
|
||||
this.resultType = resultType;
|
||||
this.referenceType = referenceType;
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,14 +41,25 @@ class TypedMetaAttribute extends NameMetaAttribute {
|
|||
|
||||
@Override
|
||||
public String getAttributeDeclarationString() {
|
||||
final boolean isQuery = "QUERY_".equals(prefix); //UGLY!
|
||||
final Metamodel entity = getHostingEntity();
|
||||
final StringBuilder declaration = new StringBuilder();
|
||||
declaration
|
||||
.append("\n/**")
|
||||
.append("\n * The query named {@value ")
|
||||
.append("\n * The ")
|
||||
.append(isQuery ? "query" : "entity graph")
|
||||
.append(" named {@value ")
|
||||
.append(prefix)
|
||||
.append(fieldName())
|
||||
.append("}\n *\n * @see ")
|
||||
.append("}\n");
|
||||
if ( query != null ) {
|
||||
declaration.append(" * <pre>");
|
||||
query.lines()
|
||||
.forEach( line -> declaration.append("\n * ").append( line ) );
|
||||
declaration.append("\n * </pre>\n");
|
||||
}
|
||||
declaration
|
||||
.append(" *\n * @see ")
|
||||
.append(entity.getQualifiedName())
|
||||
.append("\n **/\n")
|
||||
.append("public static volatile ")
|
||||
|
@ -53,7 +70,7 @@ class TypedMetaAttribute extends NameMetaAttribute {
|
|||
.append(' ')
|
||||
.append('_')
|
||||
.append(nameToMethodName(getPropertyName()));
|
||||
if ( "QUERY_".equals(prefix) ) { //UGLY!
|
||||
if ( isQuery ) {
|
||||
declaration.append('_');
|
||||
}
|
||||
declaration.append(';');
|
||||
|
|
Loading…
Reference in New Issue