HHH-18127 - Leverage hibernate-models Annotation-as-Class

This commit is contained in:
Steve Ebersole 2024-05-23 13:42:12 -05:00
parent 724f2547bc
commit 8636806510
551 changed files with 33037 additions and 13755 deletions

View File

@ -0,0 +1,3 @@
apply from: rootProject.file( 'gradle/java-module.gradle' )
apply plugin: 'version-injection'

View File

@ -0,0 +1,36 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations;
import java.io.IOException;
import java.io.Writer;
import java.util.Locale;
/**
* @author Steve Ebersole
*/
public abstract class AbstractClassWriter {
protected final Writer writer;
protected AbstractClassWriter(Writer writer) {
this.writer = writer;
}
protected void writeLine() throws IOException {
writer.write( '\n' );
}
protected void writeLine(String line, Object... args) throws IOException {
writer.write( String.format( Locale.ROOT, line, args ) );
writeLine();
}
protected void writeLine(int indentation, String line, Object... args) throws IOException {
writer.write( " " .repeat( indentation * 4 ) );
writeLine( line, args );
}
}

View File

@ -0,0 +1,68 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.lang.model.element.TypeElement;
/**
* @author Steve Ebersole
*/
public class ClassFileHelper {
public static final String GENERATION_PACKAGE = "org.hibernate.boot.models.annotations.spi";
static final Pattern CAMEL_CASE_SPLITTER = Pattern.compile( "(([A-Z]?[a-z]+)|([A-Z]))" );
static String determineConstantName(TypeElement annotationClass) {
final StringBuilder nameBuffer = new StringBuilder();
final Matcher matcher = CAMEL_CASE_SPLITTER.matcher( annotationClass.getSimpleName().toString() );
boolean firstPass = true;
while ( matcher.find() ) {
if ( !firstPass ) {
nameBuffer.append( '_' );
}
else {
firstPass = false;
}
nameBuffer.append( matcher.group(0).toUpperCase( Locale.ROOT ) );
}
return nameBuffer.toString();
}
public static Object defaultValueValue(Method declaredMethod) {
// should not get in here if there is no default
assert declaredMethod.getDefaultValue() != null;
if ( declaredMethod.getReturnType().isAnnotation() ) {
return String.format(
Locale.ROOT,
"modelContext.getAnnotationDescriptorRegistry().getDescriptor(%s.class).createUsage(modelContext)",
declaredMethod.getReturnType().getName()
);
}
if ( String.class.equals( declaredMethod.getReturnType() ) ) {
return "\"" + declaredMethod.getDefaultValue() + "\"";
}
if ( long.class.equals( declaredMethod.getReturnType() ) ) {
return declaredMethod.getDefaultValue() + "L";
}
if ( declaredMethod.getReturnType().isArray() ) {
final Class<?> componentType = declaredMethod.getReturnType().getComponentType();
return "new " + componentType.getName() + "[0]";
}
return declaredMethod.getDefaultValue();
}
}

View File

@ -0,0 +1,232 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.TypeMirror;
import org.hibernate.orm.build.annotations.structure.AnnotationDescriptor;
import org.hibernate.orm.build.annotations.structure.AnnotationType;
import org.hibernate.orm.build.annotations.structure.AttributeDescriptor;
import org.hibernate.orm.build.annotations.structure.BooleanType;
import org.hibernate.orm.build.annotations.structure.EnumType;
import org.hibernate.orm.build.annotations.structure.IntType;
import org.hibernate.orm.build.annotations.structure.LongType;
import org.hibernate.orm.build.annotations.structure.ShortType;
import org.hibernate.orm.build.annotations.structure.Type;
import static org.hibernate.orm.build.annotations.structure.StringType.STRING_TYPE;
/**
* @author Steve Ebersole
*/
@SupportedAnnotationTypes( "java.lang.annotation.Retention" )
public class ClassGeneratorProcessor extends AbstractProcessor {
public static final String JPA_PACKAGE = "jakarta.persistence";
public static final String HIBERNATE_PACKAGE = "org.hibernate.annotations";
public static final String HIBERNATE_PACKAGE2 = "org.hibernate.boot.internal";
public static final String DIALECT_OVERRIDES = "org.hibernate.annotations.DialectOverride";
private final Map<TypeElement, AnnotationDescriptor> annotationDescriptorMap = new TreeMap<>( Comparator.comparing( typeElement -> typeElement.getSimpleName().toString() ) );
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if ( roundEnv.processingOver() ) {
finishUp();
}
else {
processAnnotations( roundEnv );
}
return false;
}
private void processAnnotations(RoundEnvironment roundEnv) {
processAnnotations(
processingEnv.getElementUtils().getPackageElement( JPA_PACKAGE ),
"%sJpaAnnotation",
"org.hibernate.boot.models.JpaAnnotations"
);
processAnnotations(
processingEnv.getElementUtils().getPackageElement( HIBERNATE_PACKAGE ),
"%sAnnotation",
"org.hibernate.boot.models.HibernateAnnotations"
);
processAnnotations(
processingEnv.getElementUtils().getPackageElement( HIBERNATE_PACKAGE2 ),
"%sXmlAnnotation",
"org.hibernate.boot.models.XmlAnnotations"
);
processAnnotations(
processingEnv.getElementUtils().getTypeElement( DIALECT_OVERRIDES ),
"%sAnnotation",
"org.hibernate.boot.models.DialectOverrideAnnotations"
);
}
private void processAnnotations(PackageElement packageElement, String concreteNamePattern, String constantsClassName) {
for ( Element enclosedElement : packageElement.getEnclosedElements() ) {
if ( enclosedElement instanceof TypeElement typeElement ) {
if ( typeElement.getKind() == ElementKind.ANNOTATION_TYPE ) {
processAnnotation( typeElement, concreteNamePattern, constantsClassName, annotationDescriptorMap );
}
}
}
}
private void processAnnotations(TypeElement typeElement, String concreteNamePattern, String constantsClassName) {
for ( Element enclosedElement : typeElement.getEnclosedElements() ) {
if ( enclosedElement instanceof TypeElement nestedTypeElement ) {
if ( nestedTypeElement.getKind() == ElementKind.ANNOTATION_TYPE ) {
processAnnotation( nestedTypeElement, concreteNamePattern, constantsClassName, annotationDescriptorMap );
}
}
}
}
private void processAnnotation(
TypeElement annotationClass,
String concreteNamePattern,
String constantsClassName,
Map<TypeElement, AnnotationDescriptor> descriptorMap) {
if ( descriptorMap.containsKey( annotationClass ) ) {
// we've already processed it
return;
}
final String concreteClassName = String.format( concreteNamePattern, annotationClass.getSimpleName().toString() );
final String constantName = ClassFileHelper.determineConstantName( annotationClass );
final String repeatableContainerConstantName = resolveRepeatableContainer( annotationClass );
final AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor(
annotationClass,
concreteClassName,
constantsClassName,
constantName,
repeatableContainerConstantName,
extractAttributes( annotationClass )
);
descriptorMap.put( annotationClass, annotationDescriptor );
ConcreteClassWriter.writeClass( annotationDescriptor, processingEnv );
}
private List<AttributeDescriptor> extractAttributes(TypeElement annotationType) {
final List<? extends Element> allMembers = processingEnv.getElementUtils().getAllMembers( annotationType );
final List<AttributeDescriptor> attributeDescriptors = new ArrayList<>( allMembers.size() );
for ( Element member : allMembers ) {
if ( member.getKind() != ElementKind.METHOD ) {
// should only ever be methods anyway, but...
continue;
}
if ( !member.getEnclosingElement().equals( annotationType ) ) {
// we only want members declared on the annotation (as opposed to Object e.g.)
continue;
}
ExecutableElement memberAsExecutableElement = (ExecutableElement) member;
attributeDescriptors.add( new AttributeDescriptor(
member.getSimpleName().toString(),
determineType( member ),
memberAsExecutableElement.getDefaultValue()
) );
}
return attributeDescriptors;
}
private Type determineType(Element member) {
// member should be an ExecutableElement...
final ExecutableType memberAsExecutableType = (ExecutableType) member.asType();
return interpretType( memberAsExecutableType.getReturnType() );
}
private Type interpretType(TypeMirror type) {
return switch ( type.getKind() ) {
case BOOLEAN -> BooleanType.BOOLEAN_TYPE;
case SHORT -> ShortType.SHORT_TYPE;
case INT -> IntType.INT_TYPE;
case LONG -> LongType.LONG_TYPE;
case DECLARED -> interpretDeclaredType( type );
case ARRAY -> interpretArrayType( type );
default -> throw new IllegalStateException();
};
}
private Type interpretDeclaredType(TypeMirror type) {
final DeclaredType declaredType = (DeclaredType) type;
final Element declaredTypeAsElement = declaredType.asElement();
if ( String.class.getName().equals( declaredTypeAsElement.toString() ) ) {
return STRING_TYPE;
}
if ( declaredTypeAsElement.getKind() == ElementKind.ANNOTATION_TYPE ) {
return new AnnotationType( declaredType );
}
if ( declaredTypeAsElement.getKind() == ElementKind.ENUM ) {
return new EnumType( declaredType );
}
return new org.hibernate.orm.build.annotations.structure.DeclaredType( declaredType );
}
private Type interpretArrayType(TypeMirror type) {
final ArrayType arrayType = (ArrayType) type;
final TypeMirror componentType = arrayType.getComponentType();
return new org.hibernate.orm.build.annotations.structure.ArrayType( interpretType( componentType ) );
}
private String resolveRepeatableContainer(TypeElement annotationClass) {
// todo : need to resolve this...
return null;
}
private void finishUp() {
// jpaAnnotationDescriptorMap.forEach( (typeElement, annotationDescriptor) -> {
// ConcreteClassWriter.writeClass( annotationDescriptor, JPA_CONSTANTS_CLASS, processingEnv );
// } );
// ConstantsClassWriter.writeClass(
// JPA_CONSTANTS_CLASS,
// jpaAnnotationDescriptorMap,
// processingEnv
// );
//
// hibernateAnnotationDescriptorMap.forEach( (typeElement, annotationDescriptor) -> {
// ConcreteClassWriter.writeClass( annotationDescriptor, HIBERNATE_CONSTANTS_CLASS, processingEnv );
// } );
// ConstantsClassWriter.writeClass(
// HIBERNATE_CONSTANTS_CLASS,
// hibernateAnnotationDescriptorMap,
// processingEnv
// );
}
}

View File

@ -0,0 +1,261 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Method;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.tools.JavaFileObject;
import org.hibernate.orm.build.annotations.structure.AnnotationDescriptor;
import org.hibernate.orm.build.annotations.structure.AttributeDescriptor;
import static org.hibernate.orm.build.annotations.ClassFileHelper.GENERATION_PACKAGE;
/**
* Writes the concrete annotation class to file
*
* @author Steve Ebersole
*/
public class ConcreteClassWriter extends AbstractClassWriter {
public static void writeClass(
AnnotationDescriptor annotationDescriptor,
ProcessingEnvironment processingEnv) {
final String sourceFileName = GENERATION_PACKAGE + "." + annotationDescriptor.concreteTypeName();
final Filer filer = processingEnv.getFiler();
try {
final JavaFileObject sourceFile = filer.createSourceFile( sourceFileName, annotationDescriptor.annotationType() );
try (Writer writer = sourceFile.openWriter()) {
final ConcreteClassWriter classWriter = new ConcreteClassWriter( annotationDescriptor, writer, processingEnv );
classWriter.write();
}
}
catch (IOException e) {
throw new RuntimeException( "Unable to create concrete Annotation class source file : " + sourceFileName, e );
}
}
private final AnnotationDescriptor annotationDescriptor;
private final ProcessingEnvironment processingEnv;
public ConcreteClassWriter(
AnnotationDescriptor annotationDescriptor,
Writer writer,
ProcessingEnvironment processingEnv) {
super( writer );
this.annotationDescriptor = annotationDescriptor;
this.processingEnv = processingEnv;
}
private void write() throws IOException {
writeLine( "package %s;", GENERATION_PACKAGE );
writer.write( '\n' );
writeLine( "import java.lang.annotation.Annotation;" );
writeLine();
writeLine( "import org.hibernate.models.spi.SourceModelBuildingContext;" );
writeLine();
writeLine( "import org.jboss.jandex.AnnotationInstance;" );
writeLine();
writeLine( "import %s;", annotationDescriptor.annotationType().getQualifiedName().toString() );
writeLine();
writeLine( "import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;" );
writeLine( "import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;" );
writer.write( '\n' );
writeLine( "@SuppressWarnings({ \"ClassExplicitlyAnnotation\", \"unused\" })" );
writeLine( "@jakarta.annotation.Generated(\"org.hibernate.orm.build.annotations.ClassGeneratorProcessor\")" );
writeLine( "public class %s implements %s {", annotationDescriptor.concreteTypeName(), annotationDescriptor.annotationType().getSimpleName().toString() );
writeDescriptorConstant();
writeFields();
writeConstructors();
writeMethods();
writeLine( "}" );
}
private void writeDescriptorConstant() throws IOException {
// writeLine(
// 1,
// "public static final %s<%s,%> %s = new %s(%s.class, %s.class, %s);",
// "OrmAnnotationDescriptor",
// annotationDescriptor.annotationType().getSimpleName(),
// annotationDescriptor.concreteTypeName(),
// annotationDescriptor.constantName(),
// "OrmAnnotationDescriptor",
// annotationDescriptor.annotationType().getSimpleName(),
// annotationDescriptor.concreteTypeName(),
// annotationDescriptor.repeatableContainerConstantName()
// );
writeLine(
1,
"public static final %s<%s,%s> %s = null;",
"OrmAnnotationDescriptor",
annotationDescriptor.annotationType().getSimpleName(),
annotationDescriptor.concreteTypeName(),
annotationDescriptor.constantName()
);
writeLine();
}
private void writeFields() throws IOException {
for ( AttributeDescriptor attribute : annotationDescriptor.attributes() ) {
writeLine( 1, "private %s %s;", attribute.getType().getTypeDeclarationString(), attribute.getName() );
}
writeLine();
}
private void writeConstructors() throws IOException {
writeDefaultInitialization();
writeJdkInitialization();
writeJandexInitialization();
}
private void writeDefaultInitialization() throws IOException {
writeLine( 1, "/**" );
writeLine( 1, " * Used in creating dynamic annotation instances (e.g. from XML)" );
writeLine( 1, " */" );
writeLine( 1, "public %s(SourceModelBuildingContext modelContext) {", annotationDescriptor.concreteTypeName() );
for ( AttributeDescriptor attribute : annotationDescriptor.attributes() ) {
writeDefaultValueInitialization( attribute );
}
writeLine( 1, "}" );
writeLine();
}
private void writeDefaultValueInitialization(AttributeDescriptor attribute) throws IOException {
if ( attribute.getDefaultValue() == null || attribute.getDefaultValue().getValue() == null ) {
return;
}
writeLine( 2, "this.%s = %s;", attribute.getName(),attribute.getType().getInitializerValue( attribute.getDefaultValue() ) );
}
private void writeJdkInitialization() throws IOException {
writeLine( 1, "/**" );
writeLine( 1, " * Used in creating annotation instances from JDK variant" );
writeLine( 1, " */" );
writeLine( 1, "public %s(%s annotation, SourceModelBuildingContext modelContext) {", annotationDescriptor.concreteTypeName(), annotationDescriptor.annotationType().getSimpleName().toString() );
for ( AttributeDescriptor attributeDescriptor : annotationDescriptor.attributes() ) {
writeJdkValueInitialization( attributeDescriptor );
}
writeLine( 1, "}" );
writeLine();
}
private void writeJdkValueInitialization(AttributeDescriptor attribute) throws IOException {
writeLine(
2,
"this.%s = extractJdkValue( annotation, %s, \"%s\", modelContext );",
attribute.getName(),
annotationDescriptor.getConstantFqn(),
attribute.getName()
);
}
private void writeJandexInitialization() throws IOException {
writeLine( 1, "/**" );
writeLine( 1, " * Used in creating annotation instances from Jandex variant" );
writeLine( 1, " */" );
writeLine( 1, "public %s(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {", annotationDescriptor.concreteTypeName() );
for ( AttributeDescriptor attributeDescriptor : annotationDescriptor.attributes() ) {
writeJandexValueInitialization( attributeDescriptor );
}
writeLine( 1, "}" );
writeLine();
}
private void writeJandexValueInitialization(AttributeDescriptor attributeDescriptor) throws IOException {
final String attrName = attributeDescriptor.getName();
writeLine(
2,
"this.%s = extractJandexValue( annotation, %s, \"%s\", modelContext );",
attrName,
annotationDescriptor.getConstantFqn(),
attrName
);
}
private void writeMethods() throws IOException {
writeAnnotationTypeMethod();
writeGettersAndSetters();
writeHelperMethods();
}
private void writeAnnotationTypeMethod() throws IOException {
writeLine( 1, "@Override" );
writeLine( 1, "public Class<? extends Annotation> annotationType() {" );
writeLine( 2, "return %s.class;", annotationDescriptor.annotationType().getSimpleName() );
writeLine( 1, "}" );
writeLine();
}
private void writeGettersAndSetters() throws IOException {
for ( AttributeDescriptor attribute : annotationDescriptor.attributes() ) {
writeGetterAndSetter( attribute );
writeLine();
}
}
private void writeGetterAndSetter(AttributeDescriptor attribute) throws IOException {
// "getter"
writeLine(
1,
"@Override public %s %s() { return %s; }",
attribute.getType().getTypeDeclarationString(),
attribute.getName(),
attribute.getName()
);
// "setter"
writeLine(
1,
"public void %s(%s value) { this.%s = value; }",
attribute.getName(),
attribute.getType().getTypeDeclarationString(),
attribute.getName()
);
writeLine();
}
private void writeHelperMethods() throws IOException {
// writeLine( 1, "public static <V, A extends Annotation> V extractJdkValue(A jdkAnnotation, AttributeDescriptor<V> attributeDescriptor, SourceModelBuildingContext modelContext) {" );
// writeLine( 2, "return attributeDescriptor.getTypeDescriptor().createJdkValueExtractor( modelContext ).extractValue( jdkAnnotation, attributeDescriptor, modelContext );" );
// writeLine( 1, "}" );
// writeLine();
// writeLine( 1, "public static <V, A extends Annotation> V extractJdkValue(A jdkAnnotation, AnnotationDescriptor<A> annotationDescriptor, String attributeName, SourceModelBuildingContext modelContext) {" );
// writeLine( 2, "final AttributeDescriptor<V> attributeDescriptor = annotationDescriptor.getAttribute( attributeName );" );
// writeLine( 2, "return extractJdkValue( jdkAnnotation, attributeDescriptor, modelContext );" );
// writeLine( 1, "}" );
// writeLine();
// writeLine( 1, "public static <V> V extractJandexValue(AnnotationInstance jandexAnnotation, AttributeDescriptor<V> attributeDescriptor, SourceModelBuildingContext modelContext) {" );
// writeLine( 2, "final AnnotationValue value = jandexAnnotation.value( attributeDescriptor.getName() );" );
// writeLine( 2, "return attributeDescriptor.getTypeDescriptor().createJandexValueConverter( modelContext ).convert( value, modelContext );" );
// writeLine( 1, "}" );
// writeLine();
// writeLine( 1, "public static <V, A extends Annotation> V extractJandexValue(AnnotationInstance jandexAnnotation, AnnotationDescriptor<A> annotationDescriptor, String attributeName, SourceModelBuildingContext modelContext) {" );
// writeLine( 2, "final AttributeDescriptor<V> attributeDescriptor = %s.getAttribute( attributeName );" );
// writeLine( 2, "return extractJandexValue( jandexAnnotation, attributeDescriptor, modelContext );" );
// writeLine( 1, "}" );
}
}

View File

@ -0,0 +1,25 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import java.util.List;
import javax.lang.model.element.TypeElement;
/**
* @author Steve Ebersole
*/
public record AnnotationDescriptor(
TypeElement annotationType,
String concreteTypeName,
String constantsClassName,
String constantName,
String repeatableContainerConstantName,
List<AttributeDescriptor> attributes) {
public String getConstantFqn() {
return constantsClassName() + "." + constantName();
}
}

View File

@ -0,0 +1,36 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import java.util.Locale;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.type.DeclaredType;
/**
* @author Steve Ebersole
*/
public class AnnotationType implements Type {
private final javax.lang.model.type.DeclaredType underlyingType;
public AnnotationType(DeclaredType underlyingType) {
this.underlyingType = underlyingType;
}
@Override
public String getTypeDeclarationString() {
return underlyingType.toString();
}
@Override
public String getInitializerValue(AnnotationValue defaultValue) {
return String.format(
Locale.ROOT,
"modelContext.getAnnotationDescriptorRegistry().getDescriptor(%s.class).createUsage(modelContext)",
underlyingType.toString()
);
}
}

View File

@ -0,0 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import java.util.Locale;
import javax.lang.model.element.AnnotationValue;
/**
* @author Steve Ebersole
*/
public class ArrayType implements Type {
private final Type componentType;
public ArrayType(Type componentType) {
this.componentType = componentType;
}
@Override
public String getTypeDeclarationString() {
return componentType.getTypeDeclarationString() + "[]";
}
@Override
public String getInitializerValue(AnnotationValue defaultValue) {
return String.format( Locale.ROOT, "new %s[0]", componentType.getTypeDeclarationString() );
}
}

View File

@ -0,0 +1,36 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
/**
* @author Steve Ebersole
*/
public class AttributeDescriptor {
private final String name;
private final Type type;
private final AnnotationValue defaultValue;
public AttributeDescriptor(String name, Type type, AnnotationValue defaultValue) {
this.name = name;
this.type = type;
this.defaultValue = defaultValue;
}
public String getName() {
return name;
}
public Type getType() {
return type;
}
public AnnotationValue getDefaultValue() {
return defaultValue;
}
}

View File

@ -4,13 +4,16 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.bind.spi;
import org.hibernate.boot.model.naming.Identifier;
package org.hibernate.orm.build.annotations.structure;
/**
* @author Steve Ebersole
*/
public interface PhysicalTableReference extends PersistentTableReference {
Identifier getPhysicalTableName();
public class BooleanType implements Type {
public static final BooleanType BOOLEAN_TYPE = new BooleanType();
@Override
public String getTypeDeclarationString() {
return "boolean";
}
}

View File

@ -0,0 +1,23 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
/**
* @author Steve Ebersole
*/
public class DeclaredType implements Type {
private final javax.lang.model.type.DeclaredType underlyingType;
public DeclaredType(javax.lang.model.type.DeclaredType underlyingType) {
this.underlyingType = underlyingType;
}
@Override
public String getTypeDeclarationString() {
return underlyingType.toString();
}
}

View File

@ -0,0 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.type.DeclaredType;
/**
* @author Steve Ebersole
*/
public class EnumType implements Type {
private final DeclaredType underlyingType;
public EnumType(DeclaredType underlyingType) {
this.underlyingType = underlyingType;
}
@Override
public String getTypeDeclarationString() {
return underlyingType.toString();
}
@Override
public String getInitializerValue(AnnotationValue defaultValue) {
return underlyingType.toString() + "." + defaultValue.toString();
}
}

View File

@ -0,0 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
/**
* @author Steve Ebersole
*/
public class IntType implements Type {
public static final IntType INT_TYPE = new IntType();
@Override
public String getTypeDeclarationString() {
return "int";
}
@Override
public String getInitializerValue(AnnotationValue defaultValue) {
return defaultValue.toString();
}
}

View File

@ -0,0 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
/**
* @author Steve Ebersole
*/
public class LongType implements Type {
public static final LongType LONG_TYPE = new LongType();
@Override
public String getTypeDeclarationString() {
return "long";
}
@Override
public String getInitializerValue(AnnotationValue defaultValue) {
return Type.super.getInitializerValue( defaultValue ) + "L";
}
}

View File

@ -0,0 +1,21 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
/**
* @author Steve Ebersole
*/
public class ShortType implements Type {
public static final ShortType SHORT_TYPE = new ShortType();
@Override
public String getTypeDeclarationString() {
return "short";
}
}

View File

@ -0,0 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
/**
* Type implementation Strings
*
* @author Steve Ebersole
*/
public class StringType implements Type {
public static final StringType STRING_TYPE = new StringType();
public StringType() {
}
@Override
public String getTypeDeclarationString() {
return "String";
}
}

View File

@ -0,0 +1,20 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.orm.build.annotations.structure;
import javax.lang.model.element.AnnotationValue;
/**
* @author Steve Ebersole
*/
public interface Type {
String getTypeDeclarationString();
default String getInitializerValue(AnnotationValue defaultValue) {
return defaultValue.toString();
}
}

View File

@ -0,0 +1 @@
org.hibernate.orm.build.annotations.ClassGeneratorProcessor

View File

@ -46,6 +46,9 @@ dependencies {
compileOnly libs.jacksonXml
compileOnly dbLibs.postgresql
// annotationProcessor project( ":annotation-descriptor-generator" )
compileOnly project( ":annotation-descriptor-generator" )
testImplementation project(':hibernate-testing')
testImplementation project(':hibernate-ant')
testImplementation testLibs.shrinkwrapApi
@ -206,6 +209,22 @@ artifacts {
tests testJar
}
tasks.register( "generateAnnotationClasses", JavaCompile ) {
description = "Generate concrete classes for Hibernate and JPA annotations"
source = sourceSets.main.allJava
include "org/hibernate/annotations/*"
classpath = sourceSets.main.runtimeClasspath + sourceSets.main.compileClasspath
options.annotationProcessorPath = sourceSets.main.compileClasspath
options.compilerArgs = [
"-proc:only",
"-processor",
"org.hibernate.orm.build.annotations.ClassGeneratorProcessor"
]
destinationDirectory.set( project.layout.buildDirectory.dir( "generated/sources/annotations/" ) )
}
task generateEnversStaticMetamodel(
type: JavaCompile,
description: "Generate the Hibernate Envers revision entity static metamodel classes." ) {

View File

@ -16,7 +16,6 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.TYPE_PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
@ -32,7 +31,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
*
* @author Steve Ebersole
*/
@Target({METHOD, FIELD, TYPE, PACKAGE, CONSTRUCTOR, TYPE_PARAMETER, TYPE_USE})
@Target({METHOD, FIELD, TYPE, PACKAGE, CONSTRUCTOR, TYPE_PARAMETER})
@Retention(RUNTIME)
@Documented
public @interface Remove {

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.boot.internal;
import java.util.List;
import java.util.UUID;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
@ -18,7 +17,6 @@ import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
@ -86,28 +84,28 @@ public class GenerationStrategyInterpreter {
}
public void interpretTableGenerator(
AnnotationUsage<TableGenerator> tableGeneratorAnnotation,
TableGenerator tableGeneratorAnnotation,
IdentifierGeneratorDefinition.Builder definitionBuilder) {
definitionBuilder.setName( tableGeneratorAnnotation.getString( "name" ) );
definitionBuilder.setName( tableGeneratorAnnotation.name() );
definitionBuilder.setStrategy( org.hibernate.id.enhanced.TableGenerator.class.getName() );
definitionBuilder.addParam( org.hibernate.id.enhanced.TableGenerator.CONFIG_PREFER_SEGMENT_PER_ENTITY, "true" );
final String catalog = tableGeneratorAnnotation.getString( "catalog" );
final String catalog = tableGeneratorAnnotation.catalog();
if ( StringHelper.isNotEmpty( catalog ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, catalog );
}
final String schema = tableGeneratorAnnotation.getString( "schema" );
final String schema = tableGeneratorAnnotation.schema();
if ( StringHelper.isNotEmpty( schema ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, schema );
}
final String table = tableGeneratorAnnotation.getString( "table" );
final String table = tableGeneratorAnnotation.table();
if ( StringHelper.isNotEmpty( table ) ) {
definitionBuilder.addParam( org.hibernate.id.enhanced.TableGenerator.TABLE_PARAM, table );
}
final String pkColumnName = tableGeneratorAnnotation.getString( "pkColumnName" );
final String pkColumnName = tableGeneratorAnnotation.pkColumnName();
if ( StringHelper.isNotEmpty( pkColumnName ) ) {
definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.SEGMENT_COLUMN_PARAM,
@ -115,7 +113,7 @@ public class GenerationStrategyInterpreter {
);
}
final String pkColumnValue = tableGeneratorAnnotation.getString( "pkColumnValue" );
final String pkColumnValue = tableGeneratorAnnotation.pkColumnValue();
if ( StringHelper.isNotEmpty( pkColumnValue ) ) {
definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.SEGMENT_VALUE_PARAM,
@ -123,7 +121,7 @@ public class GenerationStrategyInterpreter {
);
}
final String valueColumnName = tableGeneratorAnnotation.getString( "valueColumnName" );
final String valueColumnName = tableGeneratorAnnotation.valueColumnName();
if ( StringHelper.isNotEmpty( valueColumnName ) ) {
definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.VALUE_COLUMN_PARAM,
@ -131,7 +129,7 @@ public class GenerationStrategyInterpreter {
);
}
final String options = tableGeneratorAnnotation.getString( "options" );
final String options = tableGeneratorAnnotation.options();
if ( StringHelper.isNotEmpty( options ) ) {
definitionBuilder.addParam(
PersistentIdentifierGenerator.OPTIONS,
@ -141,53 +139,53 @@ public class GenerationStrategyInterpreter {
definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.INCREMENT_PARAM,
String.valueOf( tableGeneratorAnnotation.getInteger( "allocationSize" ) )
String.valueOf( tableGeneratorAnnotation.allocationSize() )
);
// See comment on HHH-4884 wrt initialValue. Basically initialValue is really the stated value + 1
definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.INITIAL_PARAM,
String.valueOf( tableGeneratorAnnotation.getInteger( "initialValue" ) + 1 )
String.valueOf( tableGeneratorAnnotation.initialValue() + 1 )
);
// TODO : implement unique-constraint support
final List<AnnotationUsage<UniqueConstraint>> uniqueConstraints = tableGeneratorAnnotation.getList( "uniqueConstraints" );
final UniqueConstraint[] uniqueConstraints = tableGeneratorAnnotation.uniqueConstraints();
if ( CollectionHelper.isNotEmpty( uniqueConstraints ) ) {
LOG.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.getString( "name" ) );
LOG.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.name() );
}
}
public void interpretSequenceGenerator(
AnnotationUsage<SequenceGenerator> sequenceGeneratorAnnotation,
SequenceGenerator sequenceGeneratorAnnotation,
IdentifierGeneratorDefinition.Builder definitionBuilder) {
definitionBuilder.setName( sequenceGeneratorAnnotation.getString( "name" ) );
definitionBuilder.setName( sequenceGeneratorAnnotation.name() );
definitionBuilder.setStrategy( SequenceStyleGenerator.class.getName() );
final String catalog = sequenceGeneratorAnnotation.getString( "catalog" );
final String catalog = sequenceGeneratorAnnotation.catalog();
if ( StringHelper.isNotEmpty( catalog ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, catalog );
}
final String schema = sequenceGeneratorAnnotation.getString( "schema" );
final String schema = sequenceGeneratorAnnotation.schema();
if ( StringHelper.isNotEmpty( schema ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, schema );
}
final String sequenceName = sequenceGeneratorAnnotation.getString( "sequenceName" );
final String sequenceName = sequenceGeneratorAnnotation.sequenceName();
if ( StringHelper.isNotEmpty( sequenceName ) ) {
definitionBuilder.addParam( SequenceStyleGenerator.SEQUENCE_PARAM, sequenceName );
}
definitionBuilder.addParam(
SequenceStyleGenerator.INCREMENT_PARAM,
String.valueOf( sequenceGeneratorAnnotation.getInteger( "allocationSize" ) )
String.valueOf( sequenceGeneratorAnnotation.allocationSize() )
);
definitionBuilder.addParam(
SequenceStyleGenerator.INITIAL_PARAM,
String.valueOf( sequenceGeneratorAnnotation.getInteger( "initialValue" ) )
String.valueOf( sequenceGeneratorAnnotation.initialValue() )
);
final String options = sequenceGeneratorAnnotation.getString( "options" );
final String options = sequenceGeneratorAnnotation.options();
if ( StringHelper.isNotEmpty( options ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.OPTIONS, options );
}

View File

@ -62,9 +62,9 @@ import org.hibernate.boot.model.relational.QualifiedTableName;
import org.hibernate.boot.model.source.internal.ImplicitColumnNamingSecondPass;
import org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext;
import org.hibernate.boot.models.categorize.internal.ClassLoaderServiceLoading;
import org.hibernate.boot.models.categorize.internal.GlobalRegistrationsImpl;
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations;
import org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor;
import org.hibernate.boot.models.internal.GlobalRegistrationsImpl;
import org.hibernate.boot.models.internal.ModelsHelper;
import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.models.xml.internal.PersistenceUnitMetadataImpl;
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.boot.query.NamedHqlQueryDefinition;
@ -107,7 +107,6 @@ import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.metamodel.mapping.DiscriminatorType;
import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.models.internal.SourceModelBuildingContextImpl;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.query.named.NamedObjectRepository;
@ -233,7 +232,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
return new SourceModelBuildingContextImpl(
classLoading,
bootstrapContext.getJandexView(),
ManagedResourcesProcessor::preFillRegistries
ModelsHelper::preFillRegistries
);
}
@ -548,9 +547,9 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
private Map<CollectionClassification, CollectionTypeRegistrationDescriptor> collectionTypeRegistrations;
@Override
public void addCollectionTypeRegistration(AnnotationUsage<CollectionTypeRegistration> registrationAnnotation) {
public void addCollectionTypeRegistration(CollectionTypeRegistration registrationAnnotation) {
addCollectionTypeRegistration(
registrationAnnotation.getEnum( "classification" ),
registrationAnnotation.classification(),
toDescriptor( registrationAnnotation )
);
}
@ -572,21 +571,21 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
return collectionTypeRegistrations.get( classification );
}
private CollectionTypeRegistrationDescriptor toDescriptor(AnnotationUsage<CollectionTypeRegistration> registrationAnnotation) {
private CollectionTypeRegistrationDescriptor toDescriptor(CollectionTypeRegistration registrationAnnotation) {
return new CollectionTypeRegistrationDescriptor(
registrationAnnotation.getClassDetails( "type" ).toJavaClass(),
extractParameters( registrationAnnotation.getList( "parameters" ) )
registrationAnnotation.type(),
extractParameters( registrationAnnotation.parameters() )
);
}
private Map<String,String> extractParameters(List<AnnotationUsage<Parameter>> annotationUsages) {
private Map<String,String> extractParameters(Parameter[] annotationUsages) {
if ( CollectionHelper.isEmpty( annotationUsages ) ) {
return null;
}
final Map<String,String> result = mapOfSize( annotationUsages.size() );
for ( AnnotationUsage<Parameter> parameter : annotationUsages ) {
result.put( parameter.getString( "name" ), parameter.getString( "value" ) );
final Map<String,String> result = mapOfSize( annotationUsages.length );
for ( Parameter parameter : annotationUsages ) {
result.put( parameter.name(), parameter.value() );
}
return result;
}
@ -1369,16 +1368,16 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
}
private static AnnotatedClassType getAnnotatedClassType2(ClassDetails classDetails) {
if ( classDetails.hasAnnotationUsage( Entity.class ) ) {
if ( classDetails.hasDirectAnnotationUsage( Entity.class ) ) {
return AnnotatedClassType.ENTITY;
}
else if ( classDetails.hasAnnotationUsage( Embeddable.class ) ) {
else if ( classDetails.hasDirectAnnotationUsage( Embeddable.class ) ) {
return AnnotatedClassType.EMBEDDABLE;
}
else if ( classDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
else if ( classDetails.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
return AnnotatedClassType.MAPPED_SUPERCLASS;
}
else if ( classDetails.hasAnnotationUsage( Imported.class ) ) {
else if ( classDetails.hasDirectAnnotationUsage( Imported.class ) ) {
return AnnotatedClassType.IMPORTED;
}
else {
@ -1435,7 +1434,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
k -> new HashMap<>()
);
map.put(
property.getAttributeMember().getAnnotationUsage( MapsId.class ).getString( "value" ),
property.getAttributeMember().getDirectAnnotationUsage( MapsId.class ).value(),
property
);
}

View File

@ -20,8 +20,6 @@ import org.hibernate.boot.query.NamedProcedureCallDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.procedure.internal.NamedCallableQueryMementoImpl;
import org.hibernate.procedure.internal.Util;
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
@ -50,15 +48,15 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private final ParameterDefinitions parameterDefinitions;
private final Map<String, Object> hints;
public NamedProcedureCallDefinitionImpl(AnnotationUsage<NamedStoredProcedureQuery> annotation) {
this.registeredName = annotation.getString( "name" );
this.procedureName = annotation.getString( "procedureName" );
this.hints = new QueryHintDefinition( registeredName, annotation.getList( "hints" ) ).getHintsMap();
public NamedProcedureCallDefinitionImpl(NamedStoredProcedureQuery annotation) {
this.registeredName = annotation.name();
this.procedureName = annotation.procedureName();
this.hints = new QueryHintDefinition( registeredName, annotation.hints() ).getHintsMap();
this.resultClasses = interpretResultClasses( annotation );
this.resultSetMappings = interpretResultMappings( annotation );
this.resultClasses = annotation.resultClasses();
this.resultSetMappings = annotation.resultSetMappings();
this.parameterDefinitions = new ParameterDefinitions( annotation.getList( "parameters" ) );
this.parameterDefinitions = new ParameterDefinitions( annotation.parameters() );
final boolean specifiesResultClasses = resultClasses != null && resultClasses.length > 0;
final boolean specifiesResultSetMappings = resultSetMappings != null && resultSetMappings.length > 0;
@ -73,30 +71,6 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
}
}
private Class<?>[] interpretResultClasses(AnnotationUsage<NamedStoredProcedureQuery> annotation) {
final List<ClassDetails> resultClassDetails = annotation.getList( "resultClasses" );
if ( resultClassDetails == null ) {
return null;
}
final Class<?>[] resultClasses = new Class<?>[resultClassDetails.size()];
for ( int i = 0; i < resultClassDetails.size(); i++ ) {
resultClasses[i] = resultClassDetails.get( i ).toJavaClass();
}
return resultClasses;
}
private String[] interpretResultMappings(AnnotationUsage<NamedStoredProcedureQuery> annotation) {
final List<String> list = annotation.getList( "resultSetMappings" );
if ( list == null ) {
return null;
}
final String[] strings = new String[list.size()];
for ( int i = 0; i < list.size(); i++ ) {
strings[i] = list.get( i );
}
return strings;
}
@Override
public String getRegistrationName() {
return registeredName;
@ -164,22 +138,22 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private final ParameterStrategy parameterStrategy;
private final ParameterDefinition<?>[] parameterDefinitions;
ParameterDefinitions(List<AnnotationUsage<StoredProcedureParameter>> parameters) {
ParameterDefinitions(StoredProcedureParameter[] parameters) {
if ( CollectionHelper.isEmpty( parameters ) ) {
parameterStrategy = ParameterStrategy.POSITIONAL;
parameterDefinitions = new ParameterDefinition[0];
}
else {
final AnnotationUsage<StoredProcedureParameter> parameterAnn = parameters.get( 0 );
final boolean firstParameterHasName = StringHelper.isNotEmpty( parameterAnn.findAttributeValue( "name" ) );
final StoredProcedureParameter parameterAnn = parameters[0];
final boolean firstParameterHasName = StringHelper.isNotEmpty( parameterAnn.name() );
parameterStrategy = firstParameterHasName
? ParameterStrategy.NAMED
: ParameterStrategy.POSITIONAL;
parameterDefinitions = new ParameterDefinition[ parameters.size() ];
parameterDefinitions = new ParameterDefinition[ parameters.length ];
for ( int i = 0; i < parameters.size(); i++ ) {
for ( int i = 0; i < parameters.length; i++ ) {
// i+1 for the position because the apis say the numbers are 1-based, not zero
parameterDefinitions[i] = new ParameterDefinition<>(i + 1, parameters.get( i ));
parameterDefinitions[i] = new ParameterDefinition<>(i + 1, parameters[i]);
}
}
}
@ -203,11 +177,12 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private final ParameterMode parameterMode;
private final Class<T> type;
ParameterDefinition(int position, AnnotationUsage<StoredProcedureParameter> annotation) {
ParameterDefinition(int position, StoredProcedureParameter annotation) {
this.position = position;
this.name = normalize( annotation.getString( "name" ) );
this.parameterMode = annotation.getEnum( "mode" );
this.type = annotation.getClassDetails( "type" ).toJavaClass();
this.name = normalize( annotation.name() );
this.parameterMode = annotation.mode();
//noinspection unchecked
this.type = (Class<T>) annotation.type();
}
public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) {

View File

@ -16,20 +16,18 @@ import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.Internal;
import org.hibernate.boot.internal.GenerationStrategyInterpreter;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.annotations.internal.SequenceGeneratorJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.TableGeneratorJpaAnnotation;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.models.spi.MutableAnnotationUsage;
import org.hibernate.internal.util.StringHelper;
import jakarta.persistence.GenerationType;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TableGenerator;
import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;
import static org.hibernate.boot.internal.GenerationStrategyInterpreter.STRATEGY_INTERPRETER;
import static org.hibernate.boot.models.JpaAnnotations.SEQUENCE_GENERATOR;
import static org.hibernate.boot.models.JpaAnnotations.TABLE_GENERATOR;
import static org.hibernate.boot.models.internal.AnnotationUsageHelper.applyStringAttributeIfSpecified;
import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty;
/**
@ -153,16 +151,20 @@ public class IdentifierGeneratorDefinition implements Serializable {
private static IdentifierGeneratorDefinition buildTableGeneratorDefinition(String name) {
final Builder builder = new Builder();
final MutableAnnotationUsage<TableGenerator> tableGeneratorUsage = TABLE_GENERATOR.createUsage( null );
tableGeneratorUsage.setAttributeValue( "name", name );
final TableGeneratorJpaAnnotation tableGeneratorUsage = TABLE_GENERATOR.createUsage( null );
if ( StringHelper.isNotEmpty( name ) ) {
tableGeneratorUsage.name( name );
}
STRATEGY_INTERPRETER.interpretTableGenerator( tableGeneratorUsage, builder );
return builder.build();
}
private static IdentifierGeneratorDefinition buildSequenceGeneratorDefinition(String name) {
final Builder builder = new Builder();
final MutableAnnotationUsage<SequenceGenerator> sequenceGeneratorUsage = SEQUENCE_GENERATOR.createUsage( null );
applyStringAttributeIfSpecified( "name", name, sequenceGeneratorUsage );
final SequenceGeneratorJpaAnnotation sequenceGeneratorUsage = SEQUENCE_GENERATOR.createUsage( null );
if ( StringHelper.isNotEmpty( name ) ) {
sequenceGeneratorUsage.name( name );
}
STRATEGY_INTERPRETER.interpretSequenceGenerator( sequenceGeneratorUsage, builder );
return builder.build();
}

View File

@ -22,16 +22,15 @@ import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource;
import org.hibernate.boot.model.source.spi.AttributePath;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.internal.AnnotationUsageHelper;
import org.hibernate.boot.models.annotations.internal.ColumnJpaAnnotation;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.MutableAnnotationUsage;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.usertype.internal.AbstractTimeZoneStorageCompositeUserType;
import org.hibernate.usertype.internal.OffsetTimeCompositeUserType;
@ -64,16 +63,16 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
private Boolean isInIdClass;
private Map<String, List<AnnotationUsage<Column>>> holderColumnOverride;
private Map<String, List<AnnotationUsage<Column>>> currentPropertyColumnOverride;
private Map<String, AnnotationUsage<ColumnTransformer>> holderColumnTransformerOverride;
private Map<String, AnnotationUsage<ColumnTransformer>> currentPropertyColumnTransformerOverride;
private Map<String, List<AnnotationUsage<JoinColumn>>> holderJoinColumnOverride;
private Map<String, List<AnnotationUsage<JoinColumn>>> currentPropertyJoinColumnOverride;
private Map<String, AnnotationUsage<JoinTable>> holderJoinTableOverride;
private Map<String, AnnotationUsage<JoinTable>> currentPropertyJoinTableOverride;
private Map<String, AnnotationUsage<ForeignKey>> holderForeignKeyOverride;
private Map<String, AnnotationUsage<ForeignKey>> currentPropertyForeignKeyOverride;
private Map<String, Column[]> holderColumnOverride;
private Map<String, Column[]> currentPropertyColumnOverride;
private Map<String, ColumnTransformer> holderColumnTransformerOverride;
private Map<String, ColumnTransformer> currentPropertyColumnTransformerOverride;
private Map<String, JoinColumn[]> holderJoinColumnOverride;
private Map<String, JoinColumn[]> currentPropertyJoinColumnOverride;
private Map<String, JoinTable> holderJoinTableOverride;
private Map<String, JoinTable> currentPropertyJoinTableOverride;
private Map<String, ForeignKey> holderForeignKeyOverride;
private Map<String, ForeignKey> currentPropertyForeignKeyOverride;
AbstractPropertyHolder(
String path,
@ -181,6 +180,10 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
return context;
}
protected SourceModelBuildingContext getSourceModelContext() {
return getContext().getMetadataCollector().getSourceModelBuildingContext();
}
/**
* Set the property to be processed. property can be null
*
@ -202,22 +205,22 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
this.currentPropertyColumnOverride = null;
}
this.currentPropertyColumnTransformerOverride = buildColumnTransformerOverride( attributeMember );
this.currentPropertyColumnTransformerOverride = buildColumnTransformerOverride( attributeMember, context );
if ( this.currentPropertyColumnTransformerOverride.isEmpty() ) {
this.currentPropertyColumnTransformerOverride = null;
}
this.currentPropertyJoinColumnOverride = buildJoinColumnOverride( attributeMember, getPath() );
this.currentPropertyJoinColumnOverride = buildJoinColumnOverride( attributeMember, getPath(), context );
if ( this.currentPropertyJoinColumnOverride.isEmpty() ) {
this.currentPropertyJoinColumnOverride = null;
}
this.currentPropertyJoinTableOverride = buildJoinTableOverride( attributeMember, getPath() );
this.currentPropertyJoinTableOverride = buildJoinTableOverride( attributeMember, getPath(), context );
if ( this.currentPropertyJoinTableOverride.isEmpty() ) {
this.currentPropertyJoinTableOverride = null;
}
this.currentPropertyForeignKeyOverride = buildForeignKeyOverride( attributeMember, getPath() );
this.currentPropertyForeignKeyOverride = buildForeignKeyOverride( attributeMember, getPath(), context );
if ( this.currentPropertyForeignKeyOverride.isEmpty() ) {
this.currentPropertyForeignKeyOverride = null;
}
@ -231,8 +234,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
* These rules are here to support both JPA 2 and legacy overriding rules.
*/
@Override
public List<AnnotationUsage<Column>> getOverriddenColumn(String propertyName) {
final List<AnnotationUsage<Column>> result = getExactOverriddenColumn( propertyName );
public Column[] getOverriddenColumn(String propertyName) {
final Column[] result = getExactOverriddenColumn( propertyName );
if ( result == null ) {
if ( propertyName.contains( ".collection&&element." ) ) {
//support for non map collections where no prefix is needed
@ -244,8 +247,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
}
@Override
public AnnotationUsage<ColumnTransformer> getOverriddenColumnTransformer(String logicalColumnName) {
AnnotationUsage<ColumnTransformer> result = null;
public ColumnTransformer getOverriddenColumnTransformer(String logicalColumnName) {
ColumnTransformer result = null;
if ( parent != null ) {
result = parent.getOverriddenColumnTransformer( logicalColumnName );
}
@ -265,8 +268,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
* Get column overriding, property first, then parent, then holder
* find the overridden rules from the exact property name.
*/
private List<AnnotationUsage<Column>> getExactOverriddenColumn(String propertyName) {
List<AnnotationUsage<Column>> result = null;
private Column[] getExactOverriddenColumn(String propertyName) {
Column[] result = null;
if ( parent != null ) {
result = parent.getExactOverriddenColumn( propertyName );
}
@ -289,8 +292,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
* These rules are here to support both JPA 2 and legacy overriding rules.
*/
@Override
public List<AnnotationUsage<JoinColumn>> getOverriddenJoinColumn(String propertyName) {
final List<AnnotationUsage<JoinColumn>> result = getExactOverriddenJoinColumn( propertyName );
public JoinColumn[] getOverriddenJoinColumn(String propertyName) {
final JoinColumn[] result = getExactOverriddenJoinColumn( propertyName );
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
//support for non map collections where no prefix is needed
//TODO cache the underlying regexp
@ -302,8 +305,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
/**
* Get column overriding, property first, then parent, then holder
*/
private List<AnnotationUsage<JoinColumn>> getExactOverriddenJoinColumn(String propertyName) {
List<AnnotationUsage<JoinColumn>> result = null;
private JoinColumn[] getExactOverriddenJoinColumn(String propertyName) {
JoinColumn[] result = null;
if ( parent != null ) {
result = parent.getExactOverriddenJoinColumn( propertyName );
}
@ -320,8 +323,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
}
@Override
public AnnotationUsage<ForeignKey> getOverriddenForeignKey(String propertyName) {
final AnnotationUsage<ForeignKey> result = getExactOverriddenForeignKey( propertyName );
public ForeignKey getOverriddenForeignKey(String propertyName) {
final ForeignKey result = getExactOverriddenForeignKey( propertyName );
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
//support for non map collections where no prefix is needed
//TODO cache the underlying regexp
@ -330,8 +333,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
return result;
}
private AnnotationUsage<ForeignKey> getExactOverriddenForeignKey(String propertyName) {
AnnotationUsage<ForeignKey> result = null;
private ForeignKey getExactOverriddenForeignKey(String propertyName) {
ForeignKey result = null;
if ( parent != null ) {
result = parent.getExactOverriddenForeignKey( propertyName );
}
@ -351,11 +354,11 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
* These rules are here to support both JPA 2 and legacy overriding rules.
*/
@Override
public AnnotationUsage<JoinTable> getJoinTable(MemberDetails attributeMember) {
public JoinTable getJoinTable(MemberDetails attributeMember) {
final String propertyName = qualify( getPath(), attributeMember.getName() );
final AnnotationUsage<JoinTable> result = getOverriddenJoinTable( propertyName );
final JoinTable result = getOverriddenJoinTable( propertyName );
if ( result == null ) {
return attributeMember.getAnnotationUsage( JoinTable.class );
return attributeMember.getDirectAnnotationUsage( JoinTable.class );
}
return result;
}
@ -366,8 +369,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
*
* These rules are here to support both JPA 2 and legacy overriding rules.
*/
public AnnotationUsage<JoinTable> getOverriddenJoinTable(String propertyName) {
final AnnotationUsage<JoinTable> result = getExactOverriddenJoinTable( propertyName );
public JoinTable getOverriddenJoinTable(String propertyName) {
final JoinTable result = getExactOverriddenJoinTable( propertyName );
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
//support for non map collections where no prefix is needed
//TODO cache the underlying regexp
@ -379,8 +382,8 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
/**
* Get column overriding, property first, then parent, then holder
*/
private AnnotationUsage<JoinTable> getExactOverriddenJoinTable(String propertyName) {
AnnotationUsage<JoinTable> override = null;
private JoinTable getExactOverriddenJoinTable(String propertyName) {
JoinTable override = null;
if ( parent != null ) {
override = parent.getExactOverriddenJoinTable( propertyName );
}
@ -395,21 +398,21 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
private void buildHierarchyColumnOverride(ClassDetails element) {
ClassDetails current = element;
Map<String, List<AnnotationUsage<Column>>> columnOverride = new HashMap<>();
Map<String, AnnotationUsage<ColumnTransformer>> columnTransformerOverride = new HashMap<>();
Map<String, List<AnnotationUsage<JoinColumn>>> joinColumnOverride = new HashMap<>();
Map<String, AnnotationUsage<JoinTable>> joinTableOverride = new HashMap<>();
Map<String, AnnotationUsage<ForeignKey>> foreignKeyOverride = new HashMap<>();
Map<String, Column[]> columnOverride = new HashMap<>();
Map<String, ColumnTransformer> columnTransformerOverride = new HashMap<>();
Map<String, JoinColumn[]> joinColumnOverride = new HashMap<>();
Map<String, JoinTable> joinTableOverride = new HashMap<>();
Map<String, ForeignKey> foreignKeyOverride = new HashMap<>();
while ( current != null && !ClassDetails.OBJECT_CLASS_DETAILS.equals( current ) ) {
if ( current.hasAnnotationUsage( Entity.class )
|| current.hasAnnotationUsage( MappedSuperclass.class )
|| current.hasAnnotationUsage( Embeddable.class ) ) {
if ( current.hasDirectAnnotationUsage( Entity.class )
|| current.hasDirectAnnotationUsage( MappedSuperclass.class )
|| current.hasDirectAnnotationUsage( Embeddable.class ) ) {
//FIXME is embeddable override?
Map<String, List<AnnotationUsage<Column>>> currentOverride = buildColumnOverride( current, getPath(), context );
Map<String, AnnotationUsage<ColumnTransformer>> currentTransformerOverride = buildColumnTransformerOverride( current );
Map<String, List<AnnotationUsage<JoinColumn>>> currentJoinOverride = buildJoinColumnOverride( current, getPath() );
Map<String, AnnotationUsage<JoinTable>> currentJoinTableOverride = buildJoinTableOverride( current, getPath() );
Map<String, AnnotationUsage<ForeignKey>> currentForeignKeyOverride = buildForeignKeyOverride( current, getPath() );
Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath(), context );
Map<String, ColumnTransformer> currentTransformerOverride = buildColumnTransformerOverride( current, context );
Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath(), context );
Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride( current, getPath(), context );
Map<String, ForeignKey> currentForeignKeyOverride = buildForeignKeyOverride( current, getPath(), context );
currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
currentTransformerOverride.putAll( columnTransformerOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
@ -431,20 +434,23 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
holderForeignKeyOverride = !foreignKeyOverride.isEmpty() ? foreignKeyOverride : null;
}
private static Map<String, List<AnnotationUsage<Column>>> buildColumnOverride(
private static Map<String, Column[]> buildColumnOverride(
AnnotationTarget element,
String path,
MetadataBuildingContext context) {
final Map<String, List<AnnotationUsage<Column>>> columnOverrideMap = new HashMap<>();
final Map<String,Column[]> result = new HashMap<>();
if ( element == null ) {
return columnOverrideMap;
return result;
}
final List<AnnotationUsage<AttributeOverride>> overrides = element.getRepeatedAnnotationUsages( AttributeOverride.class );
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final Map<String, List<Column>> columnOverrideMap = new HashMap<>();
final AttributeOverride[] overrides = element.getRepeatedAnnotationUsages( AttributeOverride.class, sourceModelContext );
if ( CollectionHelper.isNotEmpty( overrides ) ) {
for ( AnnotationUsage<AttributeOverride> depAttr : overrides ) {
final String qualifiedName = StringHelper.qualify( path, depAttr.getString( "name" ) );
final AnnotationUsage<Column> column = depAttr.getNestedUsage( "column" );
for ( AttributeOverride depAttr : overrides ) {
final String qualifiedName = StringHelper.qualify( path, depAttr.name() );
final Column column = depAttr.column();
if ( columnOverrideMap.containsKey( qualifiedName ) ) {
// already an entry, just add to that List
@ -452,14 +458,14 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
}
else {
// not yet an entry, create the list and add
final List<AnnotationUsage<Column>> list = new ArrayList<>();
final List<Column> list = new ArrayList<>();
list.add( column );
columnOverrideMap.put( qualifiedName, list );
}
}
}
else if ( useColumnForTimeZoneStorage( element, context ) ) {
final AnnotationUsage<Column> column = createTemporalColumn( element, path, context );
final Column column = createTemporalColumn( element, path, context );
if ( isOffsetTimeClass( element ) ) {
columnOverrideMap.put(
path + "." + OffsetTimeCompositeUserType.LOCAL_TIME_NAME,
@ -472,55 +478,60 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
List.of( column )
);
}
final AnnotationUsage<Column> offsetColumn = createTimeZoneColumn( element, column, context );
final Column offsetColumn = createTimeZoneColumn( element, column, context );
columnOverrideMap.put(
path + "." + AbstractTimeZoneStorageCompositeUserType.ZONE_OFFSET_NAME,
List.of( offsetColumn )
);
}
return columnOverrideMap;
columnOverrideMap.forEach( (name, columns) -> {
result.put( name, columns.toArray(new Column[0]) );
} );
return result;
}
private static AnnotationUsage<Column> createTimeZoneColumn(
private static Column createTimeZoneColumn(
AnnotationTarget element,
AnnotationUsage<Column> column,
Column column,
MetadataBuildingContext context) {
final AnnotationUsage<TimeZoneColumn> timeZoneColumn = element.getAnnotationUsage( TimeZoneColumn.class );
final MutableAnnotationUsage<Column> created = JpaAnnotations.COLUMN.createUsage( context.getMetadataCollector().getSourceModelBuildingContext() );
final TimeZoneColumn timeZoneColumn = element.getDirectAnnotationUsage( TimeZoneColumn.class );
final ColumnJpaAnnotation created = JpaAnnotations.COLUMN.createUsage( context.getMetadataCollector().getSourceModelBuildingContext() );
final String columnName = timeZoneColumn != null
? timeZoneColumn.getString( "name" )
: column.getString( "name" ) + "_tz";
created.setAttributeValue( "name", columnName );
AnnotationUsageHelper.applyAttributeIfSpecified( "nullable", column.getBoolean( "nullable" ), created );
final AnnotationUsage<?> source = timeZoneColumn != null
? timeZoneColumn
: column;
AnnotationUsageHelper.applyAttributeIfSpecified( "table", source.getString( "table" ), created );
AnnotationUsageHelper.applyAttributeIfSpecified( "insertable", source.getAttributeValue( "insertable" ), created );
AnnotationUsageHelper.applyAttributeIfSpecified( "updatable", source.getAttributeValue( "updatable" ), created );
? timeZoneColumn.name()
: column.name() + "_tz";
created.name( columnName );
created.nullable( column.nullable() );
if ( timeZoneColumn != null ) {
AnnotationUsageHelper.applyStringAttributeIfSpecified( "columnDefinition", timeZoneColumn.getAttributeValue( "columnDefinition" ), created );
created.table( timeZoneColumn.table() );
created.insertable( timeZoneColumn.insertable() );
created.updatable( timeZoneColumn.updatable() );
created.columnDefinition( timeZoneColumn.columnDefinition() );
}
else {
created.table( column.table() );
created.insertable( column.insertable() );
created.updatable( column.updatable() );
created.columnDefinition( column.columnDefinition() );
}
return created;
}
private static AnnotationUsage<Column> createTemporalColumn(
private static Column createTemporalColumn(
AnnotationTarget element,
String path,
MetadataBuildingContext context) {
int precision;
int secondPrecision;
final AnnotationUsage<Column> annotatedColumn = element.getAnnotationUsage( Column.class );
final Column annotatedColumn = element.getDirectAnnotationUsage( Column.class );
if ( annotatedColumn != null ) {
if ( StringHelper.isNotEmpty( annotatedColumn.getString( "name" ) ) ) {
if ( StringHelper.isNotEmpty( annotatedColumn.name() ) ) {
return annotatedColumn;
}
precision = annotatedColumn.getInteger( "precision" );
secondPrecision = annotatedColumn.getInteger( "secondPrecision" );
precision = annotatedColumn.precision();
secondPrecision = annotatedColumn.secondPrecision();
}
else {
precision = 0;
@ -551,67 +562,68 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
)
);
final MutableAnnotationUsage<Column> usage = JpaAnnotations.COLUMN.createUsage( context.getMetadataCollector().getSourceModelBuildingContext() );
AnnotationUsageHelper.applyStringAttributeIfSpecified( "name", implicitName.getText(), usage );
usage.setAttributeValue( "precision", precision );
usage.setAttributeValue( "secondPrecision", secondPrecision );
return usage;
final ColumnJpaAnnotation created = JpaAnnotations.COLUMN.createUsage( context.getMetadataCollector().getSourceModelBuildingContext() );
if ( StringHelper.isNotEmpty( implicitName.getText() ) ) {
created.name( implicitName.getText() );
}
created.precision( precision );
created.secondPrecision( secondPrecision );
return created;
}
private static Map<String, AnnotationUsage<ColumnTransformer>> buildColumnTransformerOverride(AnnotationTarget element) {
final Map<String, AnnotationUsage<ColumnTransformer>> columnOverride = new HashMap<>();
private static Map<String, ColumnTransformer> buildColumnTransformerOverride(AnnotationTarget element, MetadataBuildingContext context) {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final Map<String, ColumnTransformer> columnOverride = new HashMap<>();
if ( element != null ) {
element.forEachAnnotationUsage( ColumnTransformer.class, (usage) -> {
columnOverride.put( usage.getString( "forColumn" ), usage );
element.forEachAnnotationUsage( ColumnTransformer.class, sourceModelContext, (usage) -> {
columnOverride.put( usage.forColumn(), usage );
} );
}
return columnOverride;
}
private static Map<String, List<AnnotationUsage<JoinColumn>>> buildJoinColumnOverride(AnnotationTarget element, String path) {
final Map<String, List<AnnotationUsage<JoinColumn>>> columnOverride = new HashMap<>();
private static Map<String, JoinColumn[]> buildJoinColumnOverride(AnnotationTarget element, String path, MetadataBuildingContext context) {
final Map<String, JoinColumn[]> columnOverride = new HashMap<>();
if ( element != null ) {
final List<AnnotationUsage<AssociationOverride>> overrides = buildAssociationOverrides( element, path );
for ( AnnotationUsage<AssociationOverride> override : overrides ) {
final AssociationOverride[] overrides = buildAssociationOverrides( element, path, context );
for ( AssociationOverride override : overrides ) {
columnOverride.put(
qualify( path, override.getString( "name" ) ),
override.getList( "joinColumns" )
qualify( path, override.name() ),
override.joinColumns()
);
}
}
return columnOverride;
}
private static Map<String, AnnotationUsage<ForeignKey>> buildForeignKeyOverride(AnnotationTarget element, String path) {
final Map<String, AnnotationUsage<ForeignKey>> foreignKeyOverride = new HashMap<>();
private static Map<String, ForeignKey> buildForeignKeyOverride(AnnotationTarget element, String path, MetadataBuildingContext context) {
final Map<String, ForeignKey> foreignKeyOverride = new HashMap<>();
if ( element != null ) {
final List<AnnotationUsage<AssociationOverride>> overrides = buildAssociationOverrides( element, path );
for ( AnnotationUsage<AssociationOverride> override : overrides ) {
final AssociationOverride[] overrides = buildAssociationOverrides( element, path, context );
for ( AssociationOverride override : overrides ) {
foreignKeyOverride.put(
qualify( path, override.getString( "name" ) ),
override.getNestedUsage( "foreignKey" )
qualify( path, override.name() ),
override.foreignKey()
);
}
}
return foreignKeyOverride;
}
private static List<AnnotationUsage<AssociationOverride>> buildAssociationOverrides(AnnotationTarget element, String path) {
final List<AnnotationUsage<AssociationOverride>> overrides = new ArrayList<>();
element.forEachAnnotationUsage( AssociationOverride.class, overrides::add );
return overrides;
private static AssociationOverride[] buildAssociationOverrides(AnnotationTarget element, String path, MetadataBuildingContext context) {
return element.getRepeatedAnnotationUsages( AssociationOverride.class, context.getMetadataCollector().getSourceModelBuildingContext() );
}
private static Map<String, AnnotationUsage<JoinTable>> buildJoinTableOverride(AnnotationTarget element, String path) {
final Map<String, AnnotationUsage<JoinTable>> result = new HashMap<>();
private static Map<String, JoinTable> buildJoinTableOverride(AnnotationTarget element, String path, MetadataBuildingContext context) {
final Map<String, JoinTable> result = new HashMap<>();
if ( element != null ) {
final List<AnnotationUsage<AssociationOverride>> overrides = buildAssociationOverrides( element, path );
for ( AnnotationUsage<AssociationOverride> override : overrides ) {
final List<AnnotationUsage<JoinColumn>> joinColumns = override.getList( "joinColumns" );
final AssociationOverride[] overrides = buildAssociationOverrides( element, path, context );
for ( AssociationOverride override : overrides ) {
final JoinColumn[] joinColumns = override.joinColumns();
if ( CollectionHelper.isEmpty( joinColumns ) ) {
result.put(
qualify( path, override.getString( "name" ) ),
override.getNestedUsage( "joinTable" )
qualify( path, override.name() ),
override.joinTable()
);
}
}

View File

@ -20,7 +20,8 @@ import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.AggregateColumn;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Component;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails;
@ -128,15 +129,16 @@ public final class AggregateComponentBinder {
MetadataBuildingContext context) {
final MemberDetails property = inferredData.getAttributeMember();
if ( property != null ) {
final AnnotationUsage<Struct> struct = property.getAnnotationUsage( Struct.class );
final Struct struct = property.getDirectAnnotationUsage( Struct.class );
if ( struct != null ) {
return toQualifiedName( struct, context );
}
final AnnotationUsage<JdbcTypeCode> jdbcTypeCode = property.getAnnotationUsage( JdbcTypeCode.class );
if ( jdbcTypeCode != null
&& ( jdbcTypeCode.getInteger( "value" ) == SqlTypes.STRUCT
|| jdbcTypeCode.getInteger( "value" ) == SqlTypes.STRUCT_ARRAY
|| jdbcTypeCode.getInteger( "value" ) == SqlTypes.STRUCT_TABLE )
final JdbcTypeCode jdbcTypeCodeAnn = property.getDirectAnnotationUsage( JdbcTypeCode.class );
if ( jdbcTypeCodeAnn != null
&& ( jdbcTypeCodeAnn.value() == SqlTypes.STRUCT
|| jdbcTypeCodeAnn.value() == SqlTypes.STRUCT_ARRAY
|| jdbcTypeCodeAnn.value() == SqlTypes.STRUCT_TABLE )
&& columns != null ) {
final List<AnnotatedColumn> columnList = columns.getColumns();
final String sqlType;
@ -149,11 +151,10 @@ public final class AggregateComponentBinder {
null,
context.getMetadataCollector().getDatabase().toIdentifier( sqlType )
);
}
}
} }
}
final AnnotationUsage<Struct> struct = returnedClassOrElement.getAnnotationUsage( Struct.class );
final Struct struct = returnedClassOrElement.getDirectAnnotationUsage( Struct.class );
if ( struct != null ) {
return toQualifiedName( struct, context );
}
@ -161,29 +162,27 @@ public final class AggregateComponentBinder {
return null;
}
private static QualifiedName toQualifiedName(AnnotationUsage<Struct> struct, MetadataBuildingContext context) {
private static QualifiedName toQualifiedName(Struct struct, MetadataBuildingContext context) {
final Database database = context.getMetadataCollector().getDatabase();
return new QualifiedNameImpl(
database.toIdentifier( struct.getString( "catalog" ) ),
database.toIdentifier( struct.getString( "schema" ) ),
database.toIdentifier( struct.getString( "name" ) )
database.toIdentifier( struct.catalog() ),
database.toIdentifier( struct.schema() ),
database.toIdentifier( struct.name() )
);
}
private static String[] determineStructAttributeNames(PropertyData inferredData, ClassDetails returnedClassOrElement) {
final MemberDetails property = inferredData.getAttributeMember();
if ( property != null ) {
final AnnotationUsage<Struct> struct = property.getAnnotationUsage( Struct.class );
final Struct struct = property.getDirectAnnotationUsage( Struct.class );
if ( struct != null ) {
final List<String> attributes = struct.getList( "attributes" );
return attributes.toArray( new String[0] );
return struct.attributes();
}
}
final AnnotationUsage<Struct> struct = returnedClassOrElement.getAnnotationUsage( Struct.class );
final Struct struct = returnedClassOrElement.getDirectAnnotationUsage( Struct.class );
if ( struct != null ) {
final List<String> attributes = struct.getList( "attributes" );
return attributes.toArray( new String[0] );
return struct.attributes();
}
return null;
@ -194,13 +193,13 @@ public final class AggregateComponentBinder {
TypeDetails returnedClass,
MetadataBuildingContext context) {
if ( property != null ) {
if ( property.hasAnnotationUsage( Struct.class ) ) {
if ( property.hasDirectAnnotationUsage( Struct.class ) ) {
return true;
}
final AnnotationUsage<JdbcTypeCode> jdbcTypeCode = property.getAnnotationUsage( JdbcTypeCode.class );
final JdbcTypeCode jdbcTypeCode = property.getDirectAnnotationUsage( JdbcTypeCode.class );
if ( jdbcTypeCode != null ) {
switch ( jdbcTypeCode.getInteger( "value" ) ) {
switch ( jdbcTypeCode.value() ) {
case SqlTypes.STRUCT:
case SqlTypes.JSON:
case SqlTypes.SQLXML:
@ -215,7 +214,7 @@ public final class AggregateComponentBinder {
}
if ( returnedClass != null ) {
return returnedClass.determineRawClass().hasAnnotationUsage( Struct.class );
return returnedClass.determineRawClass().hasDirectAnnotationUsage( Struct.class );
}
return false;

View File

@ -35,7 +35,6 @@ import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.UserDefinedObjectType;
import org.hibernate.mapping.Value;
import org.hibernate.metamodel.internal.EmbeddableHelper;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.sql.Template;
import org.hibernate.type.SqlTypes;
@ -95,9 +94,9 @@ public class AggregateComponentSecondPass implements SecondPass {
structName.getSchemaName()
);
final UserDefinedObjectType udt = new UserDefinedObjectType( "orm", namespace, structName.getObjectName() );
final AnnotationUsage<Comment> comment = returnedClassOrElement.getAnnotationUsage( Comment.class );
final Comment comment = returnedClassOrElement.getDirectAnnotationUsage( Comment.class );
if ( comment != null ) {
udt.setComment( comment.getString( "value" ) );
udt.setComment( comment.value() );
}
for ( org.hibernate.mapping.Column aggregatedColumn : aggregatedColumns ) {
udt.addColumn( aggregatedColumn );

View File

@ -30,6 +30,7 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.AggregateColumn;
import org.hibernate.mapping.CheckConstraint;
@ -39,14 +40,14 @@ import org.hibernate.mapping.Formula;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.logging.Logger;
import static org.hibernate.boot.model.internal.DialectOverridesAnnotationHelper.getOverridableAnnotation;
import static org.hibernate.boot.model.internal.BinderHelper.getPath;
import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
import static org.hibernate.boot.model.internal.DialectOverridesAnnotationHelper.getOverridableAnnotation;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
@ -501,7 +502,7 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildFormulaFromAnnotation(
AnnotationUsage<org.hibernate.annotations.Formula> formulaAnn,
org.hibernate.annotations.Formula formulaAnn,
// Comment commentAnn,
Nullability nullability,
PropertyHolder propertyHolder,
@ -522,7 +523,7 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildColumnFromNoAnnotation(
AnnotationUsage<FractionalSeconds> fractionalSeconds,
FractionalSeconds fractionalSeconds,
// Comment commentAnn,
Nullability nullability,
PropertyHolder propertyHolder,
@ -542,8 +543,8 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildColumnFromAnnotation(
AnnotationUsage<jakarta.persistence.Column> column,
AnnotationUsage<FractionalSeconds> fractionalSeconds,
jakarta.persistence.Column column,
FractionalSeconds fractionalSeconds,
// Comment commentAnn,
Nullability nullability,
PropertyHolder propertyHolder,
@ -564,8 +565,8 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildColumnsFromAnnotations(
List<AnnotationUsage<jakarta.persistence.Column>> columns,
AnnotationUsage<FractionalSeconds> fractionalSeconds,
jakarta.persistence.Column[] columns,
FractionalSeconds fractionalSeconds,
// Comment commentAnn,
Nullability nullability,
PropertyHolder propertyHolder,
@ -587,7 +588,7 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildColumnsFromAnnotations(
List<AnnotationUsage<jakarta.persistence.Column>> columns,
jakarta.persistence.Column[] columns,
// Comment commentAnn,
Nullability nullability,
PropertyHolder propertyHolder,
@ -610,9 +611,9 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildColumnOrFormulaFromAnnotation(
AnnotationUsage<jakarta.persistence.Column> column,
AnnotationUsage<org.hibernate.annotations.Formula> formulaAnn,
AnnotationUsage<FractionalSeconds> fractionalSeconds,
jakarta.persistence.Column column,
org.hibernate.annotations.Formula formulaAnn,
FractionalSeconds fractionalSeconds,
// Comment commentAnn,
Nullability nullability,
PropertyHolder propertyHolder,
@ -620,7 +621,7 @@ public class AnnotatedColumn {
Map<String, Join> secondaryTables,
MetadataBuildingContext context) {
return buildColumnsOrFormulaFromAnnotation(
column==null ? null : List.of( column ),
column==null ? null : new jakarta.persistence.Column[] {column},
formulaAnn,
fractionalSeconds,
// commentAnn,
@ -634,9 +635,9 @@ public class AnnotatedColumn {
}
public static AnnotatedColumns buildColumnsOrFormulaFromAnnotation(
List<AnnotationUsage<jakarta.persistence.Column>> columns,
AnnotationUsage<org.hibernate.annotations.Formula> formulaAnn,
AnnotationUsage<FractionalSeconds> fractionalSeconds,
jakarta.persistence.Column[] columns,
org.hibernate.annotations.Formula formulaAnn,
FractionalSeconds fractionalSeconds,
// Comment comment,
Nullability nullability,
PropertyHolder propertyHolder,
@ -652,7 +653,7 @@ public class AnnotatedColumn {
parent.setBuildingContext( context );
parent.setJoins( secondaryTables ); //unnecessary
final AnnotatedColumn formulaColumn = new AnnotatedColumn();
formulaColumn.setFormula( formulaAnn.getString( "value" ) );
formulaColumn.setFormula( formulaAnn.value() );
formulaColumn.setImplicit( false );
// formulaColumn.setBuildingContext( context );
// formulaColumn.setPropertyHolder( propertyHolder );
@ -661,8 +662,8 @@ public class AnnotatedColumn {
return parent;
}
else {
final List<AnnotationUsage<jakarta.persistence.Column>> actualColumns = overrideColumns( columns, propertyHolder, inferredData );
if ( actualColumns == null ) {
final jakarta.persistence.Column[] actualColumns = overrideColumns( columns, propertyHolder, inferredData );
if ( ArrayHelper.isEmpty( actualColumns ) ) {
return buildImplicitColumn(
fractionalSeconds,
inferredData,
@ -689,24 +690,24 @@ public class AnnotatedColumn {
}
}
private static List<AnnotationUsage<jakarta.persistence.Column>> overrideColumns(
List<AnnotationUsage<jakarta.persistence.Column>> columns,
private static jakarta.persistence.Column[] overrideColumns(
jakarta.persistence.Column[] columns,
PropertyHolder propertyHolder,
PropertyData inferredData ) {
final String path = getPath( propertyHolder, inferredData );
final List<AnnotationUsage<jakarta.persistence.Column>> overriddenCols = propertyHolder.getOverriddenColumn( path );
final jakarta.persistence.Column[] overriddenCols = propertyHolder.getOverriddenColumn( path );
if ( overriddenCols != null ) {
//check for overridden first
if ( columns != null && overriddenCols.size() != columns.size() ) {
if ( columns != null && overriddenCols.length != columns.length ) {
//TODO: unfortunately, we never actually see this nice error message, since
// PersistentClass.validate() gets called first and produces a worse message
throw new AnnotationException( "Property '" + path
+ "' specifies " + columns.size()
+ " '@AttributeOverride's but the overridden property has " + overriddenCols.size()
+ "' specifies " + columns.length
+ " '@AttributeOverride's but the overridden property has " + overriddenCols.length
+ " columns (every column must have exactly one '@AttributeOverride')" );
}
LOG.debugf( "Column(s) overridden for property %s", inferredData.getPropertyName() );
return overriddenCols.isEmpty() ? null : overriddenCols;
return ArrayHelper.isEmpty( overriddenCols ) ? null : overriddenCols;
}
else {
return columns;
@ -720,14 +721,14 @@ public class AnnotatedColumn {
String suffixForDefaultColumnName,
Map<String, Join> secondaryTables,
MetadataBuildingContext context,
List<AnnotationUsage<jakarta.persistence.Column>> actualCols,
AnnotationUsage<FractionalSeconds> fractionalSeconds) {
jakarta.persistence.Column[] actualCols,
FractionalSeconds fractionalSeconds) {
final AnnotatedColumns parent = new AnnotatedColumns();
parent.setPropertyHolder( propertyHolder );
parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
parent.setJoins( secondaryTables );
parent.setBuildingContext( context );
for ( AnnotationUsage<jakarta.persistence.Column> column : actualCols ) {
for ( jakarta.persistence.Column column : actualCols ) {
final Database database = context.getMetadataCollector().getDatabase();
final String sqlType = getSqlType( context, column );
final String tableName = getTableName( column, database );
@ -742,21 +743,22 @@ public class AnnotatedColumn {
inferredData,
suffixForDefaultColumnName,
parent,
actualCols.size(),
actualCols.length,
database,
column,
fractionalSeconds,
sqlType,
tableName
tableName,
context.getMetadataCollector().getSourceModelBuildingContext()
);
}
return parent;
}
private static String getTableName(
AnnotationUsage<jakarta.persistence.Column> column,
jakarta.persistence.Column column,
Database database) {
final String table = column.getString( "table" );
final String table = column.table();
return table.isEmpty()
? ""
: database.getJdbcEnvironment().getIdentifierHelper().toIdentifier( table ).render();
@ -764,8 +766,8 @@ public class AnnotatedColumn {
private static String getSqlType(
MetadataBuildingContext context,
AnnotationUsage<jakarta.persistence.Column> column) {
final String columnDefinition = column.getString( "columnDefinition" );
jakarta.persistence.Column column) {
final String columnDefinition = column.columnDefinition();
return columnDefinition.isEmpty()
? null
: context.getObjectNameNormalizer().applyGlobalQuoting( columnDefinition );
@ -779,33 +781,34 @@ public class AnnotatedColumn {
AnnotatedColumns parent,
int numberOfColumns,
Database database,
AnnotationUsage<jakarta.persistence.Column> column,
AnnotationUsage<FractionalSeconds> fractionalSeconds,
jakarta.persistence.Column column,
FractionalSeconds fractionalSeconds,
String sqlType,
String tableName) {
String tableName,
SourceModelBuildingContext sourceModelContext) {
final String columnName = logicalColumnName( inferredData, suffixForDefaultColumnName, database, column );
final AnnotatedColumn annotatedColumn = new AnnotatedColumn();
annotatedColumn.setLogicalColumnName( columnName );
annotatedColumn.setImplicit( false );
annotatedColumn.setSqlType( sqlType );
annotatedColumn.setLength( (long) column.getInteger( "length" ) );
annotatedColumn.setLength( (long) column.length() );
if ( fractionalSeconds != null ) {
annotatedColumn.setTemporalPrecision( fractionalSeconds.getInteger( "value" ) );
annotatedColumn.setTemporalPrecision( fractionalSeconds.value() );
}
else {
annotatedColumn.setPrecision( column.getInteger( "precision" ) );
annotatedColumn.setPrecision( column.precision() );
// The passed annotation could also be a MapKeyColumn
Integer secondPrecision = column.getAnnotationType() == jakarta.persistence.Column.class
? column.getInteger( "secondPrecision" )
Integer secondPrecision = column.annotationType() == jakarta.persistence.Column.class
? column.secondPrecision()
: null;
annotatedColumn.setTemporalPrecision( secondPrecision == null || secondPrecision == -1 ? null : secondPrecision );
}
annotatedColumn.setScale( column.getInteger( "scale" ) );
annotatedColumn.setScale( column.scale() );
annotatedColumn.handleArrayLength( inferredData );
annotatedColumn.setNullable( column.getBoolean( "nullable" ) );
annotatedColumn.setUnique( column.getBoolean( "unique" ) );
annotatedColumn.setInsertable( column.getBoolean( "insertable" ) );
annotatedColumn.setUpdatable( column.getBoolean( "updatable" ) );
annotatedColumn.setNullable( column.nullable() );
annotatedColumn.setUnique( column.unique() );
annotatedColumn.setInsertable( column.insertable() );
annotatedColumn.setUpdatable( column.updatable() );
annotatedColumn.setExplicitTableName( tableName );
annotatedColumn.setParent( parent );
annotatedColumn.applyColumnDefault( inferredData, numberOfColumns );
@ -813,14 +816,15 @@ public class AnnotatedColumn {
annotatedColumn.applyColumnCheckConstraint( column );
annotatedColumn.applyColumnOptions( column );
annotatedColumn.applyCheckConstraint( inferredData, numberOfColumns );
annotatedColumn.extractDataFromPropertyData( propertyHolder, inferredData );
annotatedColumn.extractDataFromPropertyData( propertyHolder, inferredData, sourceModelContext );
annotatedColumn.bind();
return annotatedColumn;
}
private void handleArrayLength(PropertyData inferredData) {
if ( inferredData.getAttributeMember().hasAnnotationUsage( Array.class) ) {
setArrayLength( inferredData.getAttributeMember().getAnnotationUsage( Array.class).getInteger( "length" ) );
final Array arrayAnn = inferredData.getAttributeMember().getDirectAnnotationUsage( Array.class );
if ( arrayAnn != null ) {
setArrayLength( arrayAnn.length() );
}
}
@ -828,7 +832,7 @@ public class AnnotatedColumn {
PropertyData inferredData,
String suffixForDefaultColumnName,
Database database,
AnnotationUsage<jakarta.persistence.Column> column) {
jakarta.persistence.Column column) {
final String columnName = getColumnName( database, column );
// NOTE : this is the logical column name, not the physical!
return isEmpty( columnName ) && isNotEmpty( suffixForDefaultColumnName )
@ -836,8 +840,8 @@ public class AnnotatedColumn {
: columnName;
}
private static String getColumnName(Database database, AnnotationUsage<jakarta.persistence.Column> column) {
final String name = column.getString( "name" );
private static String getColumnName(Database database, jakarta.persistence.Column column) {
final String name = column.name();
return name.isEmpty()
? null
: database.getJdbcEnvironment().getIdentifierHelper().toIdentifier( name ).render();
@ -846,7 +850,7 @@ public class AnnotatedColumn {
void applyColumnDefault(PropertyData inferredData, int length) {
final MemberDetails attributeMember = inferredData.getAttributeMember();
if ( attributeMember != null ) {
final AnnotationUsage<ColumnDefault> columnDefault = getOverridableAnnotation(
final ColumnDefault columnDefault = getOverridableAnnotation(
attributeMember,
ColumnDefault.class,
getBuildingContext()
@ -856,7 +860,7 @@ public class AnnotatedColumn {
throw new AnnotationException( "'@ColumnDefault' may only be applied to single-column mappings but '"
+ attributeMember.getName() + "' maps to " + length + " columns" );
}
setDefaultValue( columnDefault.getString( "value" ) );
setDefaultValue( columnDefault.value() );
}
}
else {
@ -867,7 +871,7 @@ public class AnnotatedColumn {
void applyGeneratedAs(PropertyData inferredData, int length) {
final MemberDetails attributeMember = inferredData.getAttributeMember();
if ( attributeMember != null ) {
final AnnotationUsage<GeneratedColumn> generatedColumn = getOverridableAnnotation(
final GeneratedColumn generatedColumn = getOverridableAnnotation(
attributeMember,
GeneratedColumn.class,
getBuildingContext()
@ -877,7 +881,7 @@ public class AnnotatedColumn {
throw new AnnotationException("'@GeneratedColumn' may only be applied to single-column mappings but '"
+ attributeMember.getName() + "' maps to " + length + " columns" );
}
setGeneratedAs( generatedColumn.getString( "value" ) );
setGeneratedAs( generatedColumn.value() );
}
}
else {
@ -885,17 +889,17 @@ public class AnnotatedColumn {
}
}
private void applyColumnCheckConstraint(AnnotationUsage<jakarta.persistence.Column> column) {
applyCheckConstraints( column.findAttributeValue( "check" ) );
private void applyColumnCheckConstraint(jakarta.persistence.Column column) {
applyCheckConstraints( column.check() );
}
void applyCheckConstraints(List<AnnotationUsage<jakarta.persistence.CheckConstraint>> checkConstraintAnnotationUsages) {
void applyCheckConstraints(jakarta.persistence.CheckConstraint[] checkConstraintAnnotationUsages) {
if ( CollectionHelper.isNotEmpty( checkConstraintAnnotationUsages ) ) {
for ( AnnotationUsage<jakarta.persistence.CheckConstraint> checkConstraintAnnotationUsage : checkConstraintAnnotationUsages ) {
for ( jakarta.persistence.CheckConstraint checkConstraintAnnotationUsage : checkConstraintAnnotationUsages ) {
addCheckConstraint(
checkConstraintAnnotationUsage.getString( "name" ),
checkConstraintAnnotationUsage.getString( "constraint" ),
checkConstraintAnnotationUsage.getString( "options" )
checkConstraintAnnotationUsage.name(),
checkConstraintAnnotationUsage.constraint(),
checkConstraintAnnotationUsage.options()
);
}
}
@ -905,27 +909,21 @@ public class AnnotatedColumn {
final MemberDetails attributeMember = inferredData.getAttributeMember();
if ( attributeMember != null ) {
// if there are multiple annotations, they're not overrideable
final AnnotationUsage<Checks> checksAnn = attributeMember.getAnnotationUsage( Checks.class );
final Checks checksAnn = attributeMember.getDirectAnnotationUsage( Checks.class );
if ( checksAnn != null ) {
final List<AnnotationUsage<Check>> checkAnns = checksAnn.getList( "value" );
for ( AnnotationUsage<Check> checkAnn : checkAnns ) {
addCheckConstraint(
checkAnn.getString( "name" ),
checkAnn.getString( "constraints" )
);
final Check[] checkAnns = checksAnn.value();
for ( Check checkAnn : checkAnns ) {
addCheckConstraint( checkAnn.name(), checkAnn.constraints() );
}
}
else {
final AnnotationUsage<Check> checkAnn = getOverridableAnnotation( attributeMember, Check.class, getBuildingContext() );
final Check checkAnn = getOverridableAnnotation( attributeMember, Check.class, getBuildingContext() );
if ( checkAnn != null ) {
if ( length != 1 ) {
throw new AnnotationException("'@Check' may only be applied to single-column mappings but '"
+ attributeMember.getName() + "' maps to " + length + " columns (use a table-level '@Check')" );
}
addCheckConstraint(
nullIfEmpty( checkAnn.getString( "name" ) ),
checkAnn.getString( "constraints" )
);
addCheckConstraint( nullIfEmpty( checkAnn.name() ), checkAnn.constraints() );
}
}
}
@ -935,7 +933,10 @@ public class AnnotatedColumn {
}
//must only be called after all setters are defined and before binding
private void extractDataFromPropertyData(PropertyHolder propertyHolder, PropertyData inferredData) {
private void extractDataFromPropertyData(
PropertyHolder propertyHolder,
PropertyData inferredData,
SourceModelBuildingContext context) {
if ( inferredData != null ) {
final MemberDetails attributeMember = inferredData.getAttributeMember();
if ( attributeMember != null ) {
@ -943,27 +944,28 @@ public class AnnotatedColumn {
processColumnTransformerExpressions( propertyHolder.getOverriddenColumnTransformer( logicalColumnName ) );
}
attributeMember.forEachAnnotationUsage( ColumnTransformer.class, this::processColumnTransformerExpressions );
attributeMember.forEachAnnotationUsage( ColumnTransformer.class, context, this::processColumnTransformerExpressions );
}
}
}
private void processColumnTransformerExpressions(AnnotationUsage<ColumnTransformer> annotation) {
private void processColumnTransformerExpressions(ColumnTransformer annotation) {
if ( annotation == null ) {
// nothing to process
return;
}
final String targetColumnName = annotation.getString( "forColumn" );
final String targetColumnName = annotation.forColumn();
if ( isEmpty( targetColumnName )
|| targetColumnName.equals( logicalColumnName != null ? logicalColumnName : "" ) ) {
readExpression = nullIfEmpty( annotation.getString( "read" ) );
writeExpression = nullIfEmpty( annotation.getString( "write" ) );
readExpression = nullIfEmpty( annotation.read() );
writeExpression = nullIfEmpty( annotation.write() );
}
}
private static AnnotatedColumns buildImplicitColumn(
AnnotationUsage<FractionalSeconds> fractionalSeconds,
FractionalSeconds fractionalSeconds,
PropertyData inferredData,
String suffixForDefaultColumnName,
Map<String, Join> secondaryTables,
@ -1001,18 +1003,18 @@ public class AnnotatedColumn {
column.applyColumnDefault( inferredData, 1 );
column.applyGeneratedAs( inferredData, 1 );
column.applyCheckConstraint( inferredData, 1 );
column.extractDataFromPropertyData( propertyHolder, inferredData );
column.extractDataFromPropertyData( propertyHolder, inferredData, context.getMetadataCollector().getSourceModelBuildingContext() );
column.handleArrayLength( inferredData );
if ( fractionalSeconds != null ) {
column.setTemporalPrecision( fractionalSeconds.getInteger( "value" ) );
column.setTemporalPrecision( fractionalSeconds.value() );
}
column.bind();
return columns;
}
public void addIndex(AnnotationUsage<Index> index, boolean inSecondPass) {
public void addIndex(Index index, boolean inSecondPass) {
if ( index != null ) {
addIndex( index.getString( "name" ), inSecondPass );
addIndex( index.name(), inSecondPass );
}
}
@ -1059,8 +1061,8 @@ public class AnnotatedColumn {
return getParent().getBuildingContext();
}
private void applyColumnOptions(AnnotationUsage<jakarta.persistence.Column> column) {
options = column.findAttributeValue( "options" );
private void applyColumnOptions(jakarta.persistence.Column column) {
options = column.options();
}
void setOptions(String options){

View File

@ -9,7 +9,6 @@ package org.hibernate.boot.model.internal;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.DiscriminatorFormula;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorColumn;
@ -45,9 +44,9 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
}
public static AnnotatedDiscriminatorColumn buildDiscriminatorColumn(
AnnotationUsage<DiscriminatorColumn> discriminatorColumn,
AnnotationUsage<DiscriminatorFormula> discriminatorFormula,
AnnotationUsage<Column> columnOverride,
DiscriminatorColumn discriminatorColumn,
DiscriminatorFormula discriminatorFormula,
Column columnOverride,
String defaultColumnName,
MetadataBuildingContext context) {
final AnnotatedColumns parent = new AnnotatedColumns();
@ -55,36 +54,36 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
final AnnotatedDiscriminatorColumn column = new AnnotatedDiscriminatorColumn( defaultColumnName );
final DiscriminatorType discriminatorType;
if ( discriminatorFormula != null ) {
final DiscriminatorType type = discriminatorFormula.getEnum( "discriminatorType" );
final DiscriminatorType type = discriminatorFormula.discriminatorType();
if ( type == DiscriminatorType.STRING ) {
discriminatorType = discriminatorColumn == null ? type : discriminatorColumn.getEnum( "discriminatorType" );
discriminatorType = discriminatorColumn == null ? type : discriminatorColumn.discriminatorType();
}
else {
discriminatorType = type;
}
column.setImplicit( false );
column.setFormula( discriminatorFormula.getString( "value" ) );
column.setFormula( discriminatorFormula.value() );
}
else if ( discriminatorColumn != null ) {
discriminatorType = discriminatorColumn.getEnum( "discriminatorType" );
discriminatorType = discriminatorColumn.discriminatorType();
column.setImplicit( false );
if ( !discriminatorColumn.getString( "columnDefinition" ).isEmpty() ) {
column.setSqlType( discriminatorColumn.getString( "columnDefinition" ) );
if ( !discriminatorColumn.columnDefinition().isEmpty() ) {
column.setSqlType( discriminatorColumn.columnDefinition() );
}
if ( !discriminatorColumn.getString( "name" ).isEmpty() ) {
column.setLogicalColumnName( discriminatorColumn.getString( "name" ) );
if ( !discriminatorColumn.name().isEmpty() ) {
column.setLogicalColumnName( discriminatorColumn.name() );
}
column.setNullable( false );
column.setOptions( discriminatorColumn.getString( "options" ) );
column.setOptions( discriminatorColumn.options() );
}
else {
discriminatorType = DiscriminatorType.STRING;
column.setImplicit( true );
}
if ( columnOverride != null ) {
column.setLogicalColumnName( columnOverride.getString( "name" ) );
column.setLogicalColumnName( columnOverride.name() );
final String columnDefinition = columnOverride.getString( "columnDefinition" );
final String columnDefinition = columnOverride.columnDefinition();
if ( !columnDefinition.isEmpty() ) {
column.setSqlType( columnDefinition );
}
@ -97,8 +96,8 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
private static void setDiscriminatorType(
DiscriminatorType type,
AnnotationUsage<DiscriminatorColumn> discriminatorColumn,
AnnotationUsage<Column> columnOverride,
DiscriminatorColumn discriminatorColumn,
Column columnOverride,
AnnotatedDiscriminatorColumn column) {
if ( type == null ) {
column.setDiscriminatorTypeName( "string" );
@ -117,10 +116,10 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
case STRING:
column.setDiscriminatorTypeName( "string" );
if ( columnOverride != null ) {
column.setLength( (long) columnOverride.getInteger( "length" ) );
column.setLength( (long) columnOverride.length() );
}
else if ( discriminatorColumn != null ) {
column.setLength( (long) discriminatorColumn.getInteger( "length" ) );
column.setLength( (long) discriminatorColumn.length() );
}
break;
default:

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.boot.model.internal;
import java.util.List;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.JoinFormula;
@ -21,7 +19,6 @@ import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.PrimaryKeyJoinColumn;
@ -74,13 +71,13 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
}
static AnnotatedJoinColumn buildJoinColumn(
AnnotationUsage<JoinColumn> joinColumn,
JoinColumn joinColumn,
String mappedBy,
AnnotatedJoinColumns parent,
PropertyHolder propertyHolder,
PropertyData inferredData) {
final String path = qualify( propertyHolder.getPath(), inferredData.getPropertyName() );
final List<AnnotationUsage<JoinColumn>> overrides = propertyHolder.getOverriddenJoinColumn( path );
final JoinColumn[] overrides = propertyHolder.getOverriddenJoinColumn( path );
if ( overrides != null ) {
//TODO: relax this restriction
throw new AnnotationException( "Property '" + path
@ -90,11 +87,11 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
}
public static AnnotatedJoinColumn buildJoinFormula(
AnnotationUsage<JoinFormula> joinFormula,
JoinFormula joinFormula,
AnnotatedJoinColumns parent) {
final AnnotatedJoinColumn formulaColumn = new AnnotatedJoinColumn();
formulaColumn.setFormula( joinFormula.getString( "value" ) );
formulaColumn.setReferencedColumn( joinFormula.getString( "referencedColumnName" ) );
formulaColumn.setFormula( joinFormula.value() );
formulaColumn.setReferencedColumn( joinFormula.referencedColumnName() );
// formulaColumn.setContext( buildingContext );
// formulaColumn.setPropertyHolder( propertyHolder );
// formulaColumn.setPropertyName( getRelativePath( propertyHolder, propertyName ) );
@ -105,7 +102,7 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
}
static AnnotatedJoinColumn buildJoinColumn(
AnnotationUsage<JoinColumn> joinColumn,
JoinColumn joinColumn,
// Comment comment,
String mappedBy,
AnnotatedJoinColumns parent,
@ -126,7 +123,7 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
}
private static AnnotatedJoinColumn explicitJoinColumn(
AnnotationUsage<JoinColumn> joinColumn,
JoinColumn joinColumn,
// Comment comment,
AnnotatedJoinColumns parent,
PropertyData inferredData,
@ -173,32 +170,32 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
// TODO default name still useful in association table
public void applyJoinAnnotation(AnnotationUsage<JoinColumn> joinColumn, String defaultName) {
public void applyJoinAnnotation(JoinColumn joinColumn, String defaultName) {
if ( joinColumn == null ) {
setImplicit( true );
}
else {
setImplicit( false );
final String name = joinColumn.getString( "name" );
final String name = joinColumn.name();
if ( !name.isEmpty() ) {
setLogicalColumnName( name );
}
final String columnDefinition = joinColumn.getString( "columnDefinition" );
final String columnDefinition = joinColumn.columnDefinition();
if ( !columnDefinition.isEmpty() ) {
setSqlType( getBuildingContext().getObjectNameNormalizer().applyGlobalQuoting( columnDefinition ) );
}
setNullable( joinColumn.getBoolean( "nullable" ) );
setUnique( joinColumn.getBoolean( "unique" ) );
setInsertable( joinColumn.getBoolean( "insertable" ) );
setUpdatable( joinColumn.getBoolean( "updatable" ) );
setReferencedColumn( joinColumn.getString( "referencedColumnName" ) );
setNullable( joinColumn.nullable() );
setUnique( joinColumn.unique() );
setInsertable( joinColumn.insertable() );
setUpdatable( joinColumn.updatable() );
setReferencedColumn( joinColumn.referencedColumnName() );
applyColumnCheckConstraint( joinColumn );
setOptions( joinColumn.getString( "options" ) );
setOptions( joinColumn.options() );
final String table = joinColumn.getString( "table" );
final String table = joinColumn.table();
if ( table.isEmpty() ) {
setExplicitTableName( "" );
}
@ -217,8 +214,8 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
* Called for {@link jakarta.persistence.InheritanceType#JOINED} entities.
*/
public static AnnotatedJoinColumn buildInheritanceJoinColumn(
AnnotationUsage<PrimaryKeyJoinColumn> primaryKeyJoinColumn,
AnnotationUsage<JoinColumn> joinColumn,
PrimaryKeyJoinColumn primaryKeyJoinColumn,
JoinColumn joinColumn,
Value identifier,
AnnotatedJoinColumns parent,
MetadataBuildingContext context) {
@ -230,8 +227,8 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
}
private static AnnotatedJoinColumn buildExplicitInheritanceJoinColumn(
AnnotationUsage<PrimaryKeyJoinColumn> primaryKeyJoinColumn,
AnnotationUsage<JoinColumn> joinColumn,
PrimaryKeyJoinColumn primaryKeyJoinColumn,
JoinColumn joinColumn,
AnnotatedJoinColumns parent,
MetadataBuildingContext context,
String defaultColumnName) {
@ -240,16 +237,16 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
final String referencedColumnName;
final String options;
if ( primaryKeyJoinColumn != null ) {
columnName = primaryKeyJoinColumn.getString( "name" );
columnDefinition = primaryKeyJoinColumn.getString( "columnDefinition" );
referencedColumnName = primaryKeyJoinColumn.getString( "referencedColumnName" );
options = primaryKeyJoinColumn.getString( "options" );
columnName = primaryKeyJoinColumn.name();
columnDefinition = primaryKeyJoinColumn.columnDefinition();
referencedColumnName = primaryKeyJoinColumn.referencedColumnName();
options = primaryKeyJoinColumn.options();
}
else {
columnName = joinColumn.getString( "name" );
columnDefinition = joinColumn.getString( "columnDefinition" );
referencedColumnName = joinColumn.getString( "referencedColumnName" );
options = joinColumn.getString( "options" );
columnName = joinColumn.name();
columnDefinition = joinColumn.columnDefinition();
referencedColumnName = joinColumn.referencedColumnName();
options = joinColumn.options();
}
final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer();
@ -474,7 +471,7 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
AnnotatedJoinColumns parent,
PropertyHolder propertyHolder,
PropertyData inferredData,
AnnotationUsage<JoinColumn> joinColumn) {
JoinColumn joinColumn) {
final AnnotatedJoinColumn column = new AnnotatedJoinColumn();
column.setImplicit( true );
// column.setPropertyHolder( propertyHolder );
@ -523,7 +520,7 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
super.setParent( parent );
}
private void applyColumnCheckConstraint(AnnotationUsage<jakarta.persistence.JoinColumn> column) {
applyCheckConstraints( column.findAttributeValue( "check" ) );
private void applyColumnCheckConstraint(jakarta.persistence.JoinColumn column) {
applyCheckConstraints( column.check() );
}
}

View File

@ -29,7 +29,7 @@ import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.cfg.RecoverableException;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join;
@ -39,7 +39,6 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.JoinColumn;
@ -77,7 +76,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
private String manyToManyOwnerSideEntityName;
public static AnnotatedJoinColumns buildJoinColumnsOrFormulas(
List<AnnotationUsage<JoinColumnOrFormula>> joinColumnOrFormulas,
JoinColumnOrFormula[] joinColumnOrFormulas,
String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder,
@ -89,10 +88,10 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
parent.setPropertyHolder( propertyHolder );
parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
parent.setMappedBy( mappedBy );
for ( AnnotationUsage<JoinColumnOrFormula> columnOrFormula : joinColumnOrFormulas ) {
final AnnotationUsage<JoinFormula> formula = columnOrFormula.getNestedUsage( "formula" );
final AnnotationUsage<JoinColumn> column = columnOrFormula.getNestedUsage( "column" );
final String annotationString = formula.getString( "value" );
for ( JoinColumnOrFormula columnOrFormula : joinColumnOrFormulas ) {
final JoinFormula formula = columnOrFormula.formula();
final JoinColumn column = columnOrFormula.column();
final String annotationString = formula.value();
if ( isNotEmpty( annotationString ) ) {
AnnotatedJoinColumn.buildJoinFormula( formula, parent );
}
@ -104,7 +103,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
}
static AnnotatedJoinColumns buildJoinColumnsWithFormula(
AnnotationUsage<JoinFormula> joinFormula,
JoinFormula joinFormula,
Map<String, Join> secondaryTables,
PropertyHolder propertyHolder,
PropertyData inferredData,
@ -119,7 +118,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
}
public static AnnotatedJoinColumns buildJoinColumns(
List<AnnotationUsage<JoinColumn>> joinColumns,
JoinColumn[] joinColumns,
// Comment comment,
String mappedBy,
Map<String, Join> joins,
@ -139,7 +138,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
}
public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
List<AnnotationUsage<JoinColumn>> joinColumns,
JoinColumn[] joinColumns,
// Comment comment,
String mappedBy,
Map<String, Join> joins,
@ -150,15 +149,15 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
assert mappedBy == null || !mappedBy.isEmpty();
final String propertyName = inferredData.getPropertyName();
final String path = qualify( propertyHolder.getPath(), propertyName );
final List<AnnotationUsage<JoinColumn>> overrides = propertyHolder.getOverriddenJoinColumn( path );
final List<AnnotationUsage<JoinColumn>> actualColumns = overrides == null ? joinColumns : overrides;
final JoinColumn[] overrides = propertyHolder.getOverriddenJoinColumn( path );
final JoinColumn[] actualColumns = overrides == null ? joinColumns : overrides;
final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
parent.setBuildingContext( context );
parent.setJoins( joins );
parent.setPropertyHolder( propertyHolder );
parent.setPropertyName( getRelativePath( propertyHolder, propertyName ) );
parent.setMappedBy( mappedBy );
if ( CollectionHelper.isEmpty( actualColumns ) ) {
if ( ArrayHelper.isEmpty( actualColumns ) ) {
AnnotatedJoinColumn.buildJoinColumn(
null,
// comment,
@ -171,7 +170,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
}
else {
parent.setMappedBy( mappedBy );
for ( AnnotationUsage<JoinColumn> actualColumn : actualColumns ) {
for ( JoinColumn actualColumn : actualColumns ) {
AnnotatedJoinColumn.buildJoinColumn(
actualColumn,
// comment,
@ -190,7 +189,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
* Called for join tables in {@link jakarta.persistence.ManyToMany} associations.
*/
public static AnnotatedJoinColumns buildJoinTableJoinColumns(
List<AnnotationUsage<JoinColumn>> joinColumns,
JoinColumn[] joinColumns,
Map<String, Join> secondaryTables,
PropertyHolder propertyHolder,
PropertyData inferredData,
@ -206,7 +205,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
AnnotatedJoinColumn.buildImplicitJoinTableJoinColumn( parent, propertyHolder, inferredData );
}
else {
for ( AnnotationUsage<JoinColumn> joinColumn : joinColumns ) {
for ( JoinColumn joinColumn : joinColumns ) {
AnnotatedJoinColumn.buildExplicitJoinTableJoinColumn( parent, propertyHolder, inferredData, joinColumn );
}
}

View File

@ -27,14 +27,15 @@ import org.hibernate.annotations.TypeRegistration;
import org.hibernate.boot.internal.GenerationStrategyInterpreter;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.model.convert.spi.RegisteredConversion;
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.type.descriptor.java.BasicJavaType;
@ -45,11 +46,7 @@ import jakarta.persistence.FetchType;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.NamedNativeQuery;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NamedStoredProcedureQuery;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.SqlResultSetMapping;
import jakarta.persistence.Table;
import jakarta.persistence.TableGenerator;
@ -58,8 +55,6 @@ import static org.hibernate.boot.model.internal.AnnotatedClassType.ENTITY;
import static org.hibernate.boot.model.internal.FilterDefBinder.bindFilterDefs;
import static org.hibernate.boot.model.internal.GeneratorBinder.buildGenerators;
import static org.hibernate.boot.model.internal.GeneratorBinder.buildIdGenerator;
import static org.hibernate.boot.model.internal.GeneratorBinder.buildSequenceIdGenerator;
import static org.hibernate.boot.model.internal.GeneratorBinder.buildTableIdGenerator;
import static org.hibernate.boot.model.internal.InheritanceState.getInheritanceStateOfSuperEntity;
import static org.hibernate.boot.model.internal.InheritanceState.getSuperclassInheritanceState;
import static org.hibernate.internal.CoreLogging.messageLogger;
@ -157,16 +152,18 @@ public final class AnnotationBinder {
}
private static void handleIdGenerators(ClassDetails packageInfoClassDetails, MetadataBuildingContext context) {
packageInfoClassDetails.forEachAnnotationUsage( SequenceGenerator.class, usage -> {
IdentifierGeneratorDefinition idGen = buildSequenceIdGenerator( usage );
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
packageInfoClassDetails.forEachAnnotationUsage( SequenceGenerator.class, sourceModelContext, (usage) -> {
IdentifierGeneratorDefinition idGen = buildIdGenerator( usage, context );
context.getMetadataCollector().addIdentifierGenerator( idGen );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
}
} );
packageInfoClassDetails.forEachAnnotationUsage( TableGenerator.class, usage -> {
IdentifierGeneratorDefinition idGen = buildTableIdGenerator( usage );
packageInfoClassDetails.forEachAnnotationUsage( TableGenerator.class, sourceModelContext, (usage) -> {
IdentifierGeneratorDefinition idGen = buildIdGenerator( usage, context );
context.getMetadataCollector().addIdentifierGenerator( idGen );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add table generator with name: {0}", idGen.getName() );
@ -175,13 +172,15 @@ public final class AnnotationBinder {
}
private static void bindGenericGenerators(AnnotationTarget annotatedElement, MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( GenericGenerator.class, usage -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( GenericGenerator.class, sourceModelContext, (usage) -> {
bindGenericGenerator( usage, context );
} );
}
private static void bindGenericGenerator(AnnotationUsage<GenericGenerator> def, MetadataBuildingContext context) {
context.getMetadataCollector().addIdentifierGenerator( buildIdGenerator( def ) );
private static void bindGenericGenerator(GenericGenerator def, MetadataBuildingContext context) {
context.getMetadataCollector().addIdentifierGenerator( buildIdGenerator( def, context ) );
}
public static void bindQueries(AnnotationTarget annotationTarget, MetadataBuildingContext context) {
@ -190,41 +189,47 @@ public final class AnnotationBinder {
}
private static void bindNamedHibernateQueries(AnnotationTarget annotationTarget, MetadataBuildingContext context) {
annotationTarget.forEachAnnotationUsage( org.hibernate.annotations.NamedQuery.class, (usage) -> QueryBinder.bindQuery(
usage,
context
) );
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotationTarget.forEachAnnotationUsage( org.hibernate.annotations.NamedNativeQuery.class, (usage) -> QueryBinder.bindNativeQuery(
usage,
context
) );
annotationTarget.forEachRepeatedAnnotationUsages(
HibernateAnnotations.NAMED_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindQuery( usage, context )
);
annotationTarget.forEachRepeatedAnnotationUsages(
HibernateAnnotations.NAMED_NATIVE_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindNativeQuery( usage, context )
);
}
private static void bindNamedJpaQueries(AnnotationTarget annotationTarget, MetadataBuildingContext context) {
annotationTarget.forEachAnnotationUsage( SqlResultSetMapping.class, (usage) -> QueryBinder.bindSqlResultSetMapping(
usage,
context,
false
) );
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotationTarget.forEachAnnotationUsage( NamedQuery.class, (usage) -> QueryBinder.bindQuery(
usage,
context,
false
) );
annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.SQL_RESULT_SET_MAPPING,
sourceModelContext,
(usage) -> QueryBinder.bindSqlResultSetMapping( usage, context,false )
);
annotationTarget.forEachAnnotationUsage( NamedNativeQuery.class, (usage) -> QueryBinder.bindNativeQuery(
usage,
context,
false
) );
annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.NAMED_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindQuery( usage, context, false )
);
annotationTarget.forEachAnnotationUsage( NamedStoredProcedureQuery.class, (usage) -> QueryBinder.bindNamedStoredProcedureQuery(
usage,
context,
false
) );
annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.NAMED_NATIVE_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindNativeQuery( usage, context, false )
);
annotationTarget.forEachRepeatedAnnotationUsages(
JpaAnnotations.NAMED_STORED_PROCEDURE_QUERY,
sourceModelContext,
(usage) -> QueryBinder.bindNamedStoredProcedureQuery( usage, context, false )
);
}
/**
@ -259,26 +264,26 @@ public final class AnnotationBinder {
}
private static void handleImport(ClassDetails annotatedClass, MetadataBuildingContext context) {
if ( annotatedClass.hasAnnotationUsage( Imported.class ) ) {
if ( annotatedClass.hasDirectAnnotationUsage( Imported.class ) ) {
final String qualifiedName = annotatedClass.getName();
final String name = unqualify( qualifiedName );
final String rename = annotatedClass.getAnnotationUsage( Imported.class ).getString( "rename" );
final String rename = annotatedClass.getDirectAnnotationUsage( Imported.class ).rename();
context.getMetadataCollector().addImport( rename.isEmpty() ? name : rename, qualifiedName );
}
}
private static void detectMappedSuperclassProblems(ClassDetails annotatedClass) {
if ( annotatedClass.hasAnnotationUsage( MappedSuperclass.class ) ) {
if ( annotatedClass.hasDirectAnnotationUsage( MappedSuperclass.class ) ) {
//@Entity and @MappedSuperclass on the same class leads to a NPE down the road
if ( annotatedClass.hasAnnotationUsage( Entity.class ) ) {
if ( annotatedClass.hasDirectAnnotationUsage( Entity.class ) ) {
throw new AnnotationException( "Type '" + annotatedClass.getName()
+ "' is annotated both '@Entity' and '@MappedSuperclass'" );
}
if ( annotatedClass.hasAnnotationUsage( Table.class ) ) {
if ( annotatedClass.hasDirectAnnotationUsage( Table.class ) ) {
throw new AnnotationException( "Mapped superclass '" + annotatedClass.getName()
+ "' may not specify a '@Table'" );
}
if ( annotatedClass.hasAnnotationUsage( Inheritance.class ) ) {
if ( annotatedClass.hasDirectAnnotationUsage( Inheritance.class ) ) {
throw new AnnotationException( "Mapped superclass '" + annotatedClass.getName()
+ "' may not specify an '@Inheritance' mapping strategy" );
}
@ -292,15 +297,16 @@ public final class AnnotationBinder {
.getServiceRegistry()
.getService( ManagedBeanRegistry.class );
annotatedElement.forEachAnnotationUsage( JavaTypeRegistration.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( JavaTypeRegistration.class, sourceModelContext, (usage) -> {
handleJavaTypeRegistration( context, managedBeanRegistry, usage );
} );
annotatedElement.forEachAnnotationUsage( JdbcTypeRegistration.class, (usage) -> {
annotatedElement.forEachAnnotationUsage( JdbcTypeRegistration.class, sourceModelContext, (usage) -> {
handleJdbcTypeRegistration( context, managedBeanRegistry, usage );
} );
annotatedElement.forEachAnnotationUsage( CollectionTypeRegistration.class, (usage) -> {
annotatedElement.forEachAnnotationUsage( CollectionTypeRegistration.class, sourceModelContext, (usage) -> {
context.getMetadataCollector().addCollectionTypeRegistration( usage );
} );
}
@ -308,12 +314,12 @@ public final class AnnotationBinder {
private static void handleJdbcTypeRegistration(
MetadataBuildingContext context,
ManagedBeanRegistry managedBeanRegistry,
AnnotationUsage<JdbcTypeRegistration> annotation) {
final Class<? extends JdbcType> jdbcTypeClass = annotation.getClassDetails( "value" ).toJavaClass();
JdbcTypeRegistration annotation) {
final Class<? extends JdbcType> jdbcTypeClass = annotation.value();
final JdbcType jdbcType = !context.getBuildingOptions().isAllowExtensionsInCdi()
? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass )
: managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance();
final Integer registrationCode = annotation.getInteger( "registrationCode" );
final int registrationCode = annotation.registrationCode();
final int typeCode = registrationCode == Integer.MIN_VALUE
? jdbcType.getDefaultSqlTypeCode()
: registrationCode;
@ -323,13 +329,13 @@ public final class AnnotationBinder {
private static void handleJavaTypeRegistration(
MetadataBuildingContext context,
ManagedBeanRegistry managedBeanRegistry,
AnnotationUsage<JavaTypeRegistration> annotation) {
final Class<? extends BasicJavaType<?>> javaTypeClass = annotation.getClassDetails( "descriptorClass" ).toJavaClass();
JavaTypeRegistration annotation) {
final Class<? extends BasicJavaType<?>> javaTypeClass = annotation.descriptorClass();
final BasicJavaType<?> javaType = !context.getBuildingOptions().isAllowExtensionsInCdi()
? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass )
: managedBeanRegistry.getBean( javaTypeClass ).getBeanInstance();
context.getMetadataCollector().addJavaTypeRegistration(
annotation.getClassDetails( "javaType" ).toJavaClass(),
annotation.javaType(),
javaType
);
}
@ -337,24 +343,27 @@ public final class AnnotationBinder {
private static void bindEmbeddableInstantiatorRegistrations(
AnnotationTarget annotatedElement,
MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( EmbeddableInstantiatorRegistration.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( EmbeddableInstantiatorRegistration.class, sourceModelContext, (usage) -> {
handleEmbeddableInstantiatorRegistration( context, usage );
} );
}
private static void handleEmbeddableInstantiatorRegistration(
MetadataBuildingContext context,
AnnotationUsage<EmbeddableInstantiatorRegistration> annotation) {
EmbeddableInstantiatorRegistration annotation) {
context.getMetadataCollector().registerEmbeddableInstantiator(
annotation.getClassDetails( "embeddableClass" ).toJavaClass(),
annotation.getClassDetails( "instantiator" ).toJavaClass()
annotation.embeddableClass(),
annotation.instantiator()
);
}
private static void bindCompositeUserTypeRegistrations(
AnnotationTarget annotatedElement,
MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( CompositeTypeRegistration.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( CompositeTypeRegistration.class, sourceModelContext, (usage) -> {
handleCompositeUserTypeRegistration( context, usage );
} );
}
@ -362,44 +371,46 @@ public final class AnnotationBinder {
private static void bindUserTypeRegistrations(
AnnotationTarget annotatedElement,
MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( TypeRegistration.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( TypeRegistration.class, sourceModelContext, (usage) -> {
handleUserTypeRegistration( context, usage );
} );
}
private static void handleUserTypeRegistration(
MetadataBuildingContext context,
AnnotationUsage<TypeRegistration> compositeTypeRegistration) {
TypeRegistration compositeTypeRegistration) {
// TODO: check that the two classes agree, i.e. that
// the user type knows how to handle the type
context.getMetadataCollector().registerUserType(
compositeTypeRegistration.getClassDetails( "basicClass" ).toJavaClass(),
compositeTypeRegistration.getClassDetails( "userType" ).toJavaClass()
compositeTypeRegistration.basicClass(),
compositeTypeRegistration.userType()
);
}
private static void handleCompositeUserTypeRegistration(
MetadataBuildingContext context,
AnnotationUsage<CompositeTypeRegistration> compositeTypeRegistration) {
CompositeTypeRegistration compositeTypeRegistration) {
// TODO: check that the two classes agree, i.e. that
// the user type knows how to handle the type
context.getMetadataCollector().registerCompositeUserType(
compositeTypeRegistration.getClassDetails( "embeddableClass" ).toJavaClass(),
compositeTypeRegistration.getClassDetails( "userType" ).toJavaClass()
compositeTypeRegistration.embeddableClass(),
compositeTypeRegistration.userType()
);
}
private static void bindConverterRegistrations(AnnotationTarget container, MetadataBuildingContext context) {
container.forEachAnnotationUsage( ConverterRegistration.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
container.forEachAnnotationUsage( ConverterRegistration.class, sourceModelContext, (usage) -> {
handleConverterRegistration( usage, context );
} );
}
private static void handleConverterRegistration(AnnotationUsage<ConverterRegistration> registration, MetadataBuildingContext context) {
private static void handleConverterRegistration(ConverterRegistration registration, MetadataBuildingContext context) {
context.getMetadataCollector().getConverterRegistry().addRegisteredConversion( new RegisteredConversion(
registration.getClassDetails( "domainType" ).toJavaClass(),
registration.getClassDetails( "converter" ).toJavaClass(),
registration.getBoolean( "autoApply" ),
registration.domainType(),
registration.converter(),
registration.autoApply(),
context
) );
}
@ -419,18 +430,19 @@ public final class AnnotationBinder {
}
private static void bindFetchProfiles(AnnotationTarget annotatedElement, MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( FetchProfile.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( FetchProfile.class, sourceModelContext, (usage) -> {
bindFetchProfile( usage, context );
} );
}
private static void bindFetchProfile(AnnotationUsage<FetchProfile> fetchProfile, MetadataBuildingContext context) {
final String name = fetchProfile.getString( "name" );
private static void bindFetchProfile(FetchProfile fetchProfile, MetadataBuildingContext context) {
final String name = fetchProfile.name();
if ( reuseOrCreateFetchProfile( context, name ) ) {
final List<AnnotationUsage<FetchOverride>> fetchOverrides = fetchProfile.getList( "fetchOverrides" );
for ( AnnotationUsage<FetchOverride> fetchOverride : fetchOverrides ) {
final FetchType type = fetchOverride.getEnum( "fetch" );
final FetchMode mode = fetchOverride.getEnum( "mode" );
final FetchOverride[] fetchOverrides = fetchProfile.fetchOverrides();
for ( FetchOverride fetchOverride : fetchOverrides ) {
final FetchType type = fetchOverride.fetch();
final FetchMode mode = fetchOverride.mode();
if ( type == FetchType.LAZY && mode == FetchMode.JOIN ) {
throw new AnnotationException(
"Fetch profile '" + name
@ -476,7 +488,7 @@ public final class AnnotationBinder {
final InheritanceState superclassState = getSuperclassInheritanceState( clazz, inheritanceStatePerClass );
final InheritanceState state = new InheritanceState( clazz, inheritanceStatePerClass, buildingContext );
final AnnotatedClassType classType = buildingContext.getMetadataCollector().getClassType( clazz );
if ( classType == EMBEDDABLE && !clazz.hasAnnotationUsage( Imported.class ) ) {
if ( classType == EMBEDDABLE && !clazz.hasDirectAnnotationUsage( Imported.class ) ) {
final String className = clazz.getName();
buildingContext.getMetadataCollector().addImport( unqualify( className ), className );
}

View File

@ -8,7 +8,6 @@ package org.hibernate.boot.model.internal;
import java.lang.reflect.ParameterizedType;
import java.util.HashMap;
import java.util.List;
import org.hibernate.annotations.Parameter;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
@ -16,7 +15,6 @@ import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
@ -41,11 +39,11 @@ import static org.hibernate.internal.util.collections.CollectionHelper.mapOfSize
* @author Steve Ebersole
*/
public class AnnotationHelper {
public static HashMap<String, String> extractParameterMap(List<AnnotationUsage<Parameter>> parameters) {
final HashMap<String,String> paramMap = mapOfSize( parameters.size() );
parameters.forEach( (usage) -> {
paramMap.put( usage.getString( "name" ), usage.getString( "value" ) );
} );
public static HashMap<String, String> extractParameterMap(Parameter[] parameters) {
final HashMap<String,String> paramMap = mapOfSize( parameters.length );
for ( int i = 0; i < parameters.length; i++ ) {
paramMap.put( parameters[i].name(), parameters[i].value() );
}
return paramMap;
}

View File

@ -20,7 +20,6 @@ import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.Property;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.MemberDetails;
import jakarta.persistence.Column;
@ -44,7 +43,7 @@ public class AnyBinder {
AnnotatedJoinColumns joinColumns) {
//check validity
if ( property.hasAnnotationUsage( Columns.class ) ) {
if ( property.hasDirectAnnotationUsage( Columns.class ) ) {
throw new AnnotationException(
String.format(
Locale.ROOT,
@ -55,9 +54,9 @@ public class AnyBinder {
);
}
final AnnotationUsage<Cascade> hibernateCascade = property.getAnnotationUsage( Cascade.class );
final AnnotationUsage<OnDelete> onDeleteAnn = property.getAnnotationUsage( OnDelete.class );
final AnnotationUsage<JoinTable> assocTable = propertyHolder.getJoinTable( property );
final Cascade hibernateCascade = property.getDirectAnnotationUsage( Cascade.class );
final OnDelete onDeleteAnn = property.getDirectAnnotationUsage( OnDelete.class );
final JoinTable assocTable = propertyHolder.getJoinTable( property );
if ( assocTable != null ) {
final Join join = propertyHolder.addJoin( assocTable, false );
for ( AnnotatedJoinColumn joinColumn : joinColumns.getJoinColumns() ) {
@ -68,7 +67,7 @@ public class AnyBinder {
getCascadeStrategy( null, hibernateCascade, false, context ),
//@Any has no cascade attribute
joinColumns,
onDeleteAnn == null ? null : onDeleteAnn.getEnum( "action" ),
onDeleteAnn == null ? null : onDeleteAnn.action(),
nullability,
propertyHolder,
inferredData,
@ -89,15 +88,15 @@ public class AnyBinder {
boolean isIdentifierMapper,
MetadataBuildingContext context) {
final MemberDetails property = inferredData.getAttributeMember();
final AnnotationUsage<org.hibernate.annotations.Any> any = property.getAnnotationUsage( org.hibernate.annotations.Any.class );
final org.hibernate.annotations.Any any = property.getDirectAnnotationUsage( org.hibernate.annotations.Any.class );
if ( any == null ) {
throw new AssertionFailure( "Missing @Any annotation: " + getPath( propertyHolder, inferredData ) );
}
final boolean lazy = any.getEnum( "fetch" ) == FetchType.LAZY;
final boolean optional = any.getBoolean( "optional" );
final boolean lazy = any.fetch() == FetchType.LAZY;
final boolean optional = any.optional();
final Any value = BinderHelper.buildAnyValue(
property.getAnnotationUsage( Column.class ),
property.getDirectAnnotationUsage( Column.class ),
getOverridableAnnotation( property, Formula.class, context ),
columns,
inferredData,

View File

@ -7,8 +7,6 @@
package org.hibernate.boot.model.internal;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.MemberDetails;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Convert;
@ -40,11 +38,11 @@ public class AttributeConversionInfo {
this.source = source;
}
public AttributeConversionInfo(AnnotationUsage<Convert> convertAnnotation, AnnotationTarget source) {
public AttributeConversionInfo(Convert convertAnnotation, AnnotationTarget source) {
this(
convertAnnotation.getClassDetails( "converter" ).toJavaClass(),
convertAnnotation.getBoolean( "disableConversion" ),
convertAnnotation.getString( "attributeName" ),
convertAnnotation.converter(),
convertAnnotation.disableConversion(),
convertAnnotation.attributeName(),
source
);
}

View File

@ -60,10 +60,10 @@ import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.ParameterizedTypeDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBean;
@ -184,6 +184,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
this.buildingContext = buildingContext;
}
protected SourceModelBuildingContext getSourceModelContext() {
return buildingContext.getMetadataCollector().getSourceModelBuildingContext();
}
@Override
public TypeConfiguration getTypeConfiguration() {
@ -348,19 +351,19 @@ public class BasicValueBinder implements JdbcTypeIndicators {
: typeDetails;
if ( kind != Kind.LIST_INDEX && kind != Kind.MAP_KEY ) {
isLob = valueMember.hasAnnotationUsage( Lob.class );
isLob = valueMember.hasDirectAnnotationUsage( Lob.class );
}
if ( getDialect().getNationalizationSupport() == NationalizationSupport.EXPLICIT ) {
isNationalized = buildingContext.getBuildingOptions().useNationalizedCharacterData()
|| valueMember.locateAnnotationUsage( Nationalized.class ) != null;
|| valueMember.locateAnnotationUsage( Nationalized.class, getSourceModelContext() ) != null;
}
applyJpaConverter( valueMember, converterDescriptor );
final Class<? extends UserType<?>> userTypeImpl = kind.mappingAccess.customType( valueMember );
final Class<? extends UserType<?>> userTypeImpl = kind.mappingAccess.customType( valueMember, getSourceModelContext() );
if ( userTypeImpl != null ) {
applyExplicitType( userTypeImpl, kind.mappingAccess.customTypeParameters( valueMember ) );
applyExplicitType( userTypeImpl, kind.mappingAccess.customTypeParameters( valueMember, getSourceModelContext() ) );
// An explicit custom UserType has top precedence when we get to BasicValue resolution.
return;
@ -418,7 +421,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
private void prepareCollectionId(MemberDetails attributeMember) {
final AnnotationUsage<CollectionId> collectionIdAnn = attributeMember.getAnnotationUsage( CollectionId.class );
final CollectionId collectionIdAnn = attributeMember.getDirectAnnotationUsage( CollectionId.class );
if ( collectionIdAnn == null ) {
throw new MappingException( "idbag mapping missing @CollectionId" );
}
@ -430,10 +433,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
implicitJavaTypeAccess = (typeConfiguration) -> null;
explicitJavaTypeAccess = (typeConfiguration) -> {
final AnnotationUsage<CollectionIdJavaType> javaTypeAnn = attributeMember.locateAnnotationUsage( CollectionIdJavaType.class );
final CollectionIdJavaType javaTypeAnn = attributeMember.locateAnnotationUsage( CollectionIdJavaType.class, getSourceModelContext() );
if ( javaTypeAnn != null ) {
final ClassDetails implDetails = javaTypeAnn.getClassDetails( "value" );
final Class<? extends BasicJavaType<?>> javaTypeClass = normalizeJavaType( implDetails.toJavaClass() );
final Class<? extends BasicJavaType<?>> javaTypeClass = javaTypeAnn.value();
if ( javaTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass );
@ -447,10 +449,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
};
explicitJdbcTypeAccess = (typeConfiguration) -> {
final AnnotationUsage<CollectionIdJdbcType> jdbcTypeAnn = attributeMember.locateAnnotationUsage( CollectionIdJdbcType.class );
final CollectionIdJdbcType jdbcTypeAnn = attributeMember.locateAnnotationUsage( CollectionIdJdbcType.class, getSourceModelContext() );
if ( jdbcTypeAnn != null ) {
final ClassDetails implDetails = jdbcTypeAnn.getClassDetails( "value" );
final Class<? extends JdbcType> jdbcTypeClass = normalizeJdbcType( implDetails.toJavaClass() );
final Class<? extends JdbcType> jdbcTypeClass = jdbcTypeAnn.value();
if ( jdbcTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass );
@ -460,9 +461,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<CollectionIdJdbcTypeCode> jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( CollectionIdJdbcTypeCode.class );
final CollectionIdJdbcTypeCode jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( CollectionIdJdbcTypeCode.class, getSourceModelContext() );
if ( jdbcTypeCodeAnn != null ) {
final int code = jdbcTypeCodeAnn.getInteger( "value" );
final int code = jdbcTypeCodeAnn.value();
if ( code != Integer.MIN_VALUE ) {
return typeConfiguration.getJdbcTypeRegistry().getDescriptor( code );
}
@ -472,10 +473,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
};
explicitMutabilityAccess = (typeConfiguration) -> {
final AnnotationUsage<CollectionIdMutability> mutabilityAnn = attributeMember.locateAnnotationUsage( CollectionIdMutability.class );
final CollectionIdMutability mutabilityAnn = attributeMember.locateAnnotationUsage( CollectionIdMutability.class, getSourceModelContext() );
if ( mutabilityAnn != null ) {
final ClassDetails implDetails = mutabilityAnn.getClassDetails( "value" );
final Class<? extends MutabilityPlan<?>> mutabilityClass = implDetails.toJavaClass();
final Class<? extends MutabilityPlan<?>> mutabilityClass = mutabilityAnn.value();
if ( mutabilityClass != null ) {
return resolveMutability( mutabilityClass );
}
@ -509,7 +509,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
// if there is a UserType, see if its Class is annotated with mutability-related annotations
final Class<? extends UserType<?>> customTypeImpl = Kind.ATTRIBUTE.mappingAccess.customType( attributeMember );
final Class<? extends UserType<?>> customTypeImpl = Kind.ATTRIBUTE.mappingAccess.customType( attributeMember, getSourceModelContext() );
if ( customTypeImpl != null ) {
final Mutability customTypeMutabilityAnn = customTypeImpl.getAnnotation( Mutability.class );
if ( customTypeMutabilityAnn != null ) {
@ -543,23 +543,22 @@ public class BasicValueBinder implements JdbcTypeIndicators {
return rawKeyClassDetails.toJavaClass();
};
final AnnotationUsage<MapKeyEnumerated> mapKeyEnumeratedAnn = attributeMember.getAnnotationUsage( MapKeyEnumerated.class );
final MapKeyEnumerated mapKeyEnumeratedAnn = attributeMember.getDirectAnnotationUsage( MapKeyEnumerated.class );
if ( mapKeyEnumeratedAnn != null ) {
enumType = mapKeyEnumeratedAnn.getEnum( "value" );
enumType = mapKeyEnumeratedAnn.value();
}
final AnnotationUsage<MapKeyTemporal> mapKeyTemporalAnn = attributeMember.getAnnotationUsage( MapKeyTemporal.class );
final MapKeyTemporal mapKeyTemporalAnn = attributeMember.getDirectAnnotationUsage( MapKeyTemporal.class );
if ( mapKeyTemporalAnn != null ) {
temporalPrecision = mapKeyTemporalAnn.getEnum( "value" );
temporalPrecision = mapKeyTemporalAnn.value();
}
final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi();
explicitJdbcTypeAccess = typeConfiguration -> {
final AnnotationUsage<MapKeyJdbcType> jdbcTypeAnn = attributeMember.locateAnnotationUsage( MapKeyJdbcType.class );
final MapKeyJdbcType jdbcTypeAnn = attributeMember.locateAnnotationUsage( MapKeyJdbcType.class, getSourceModelContext() );
if ( jdbcTypeAnn != null ) {
final ClassDetails implDetails = jdbcTypeAnn.getClassDetails( "value" );
final Class<? extends JdbcType> jdbcTypeClass = normalizeJdbcType( implDetails.toJavaClass() );
final Class<? extends JdbcType> jdbcTypeClass = jdbcTypeAnn.value();
if ( jdbcTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass );
@ -568,9 +567,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<MapKeyJdbcTypeCode> jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( MapKeyJdbcTypeCode.class );
final MapKeyJdbcTypeCode jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( MapKeyJdbcTypeCode.class, getSourceModelContext() );
if ( jdbcTypeCodeAnn != null ) {
final int jdbcTypeCode = jdbcTypeCodeAnn.getInteger( "value" );
final int jdbcTypeCode = jdbcTypeCodeAnn.value();
if ( jdbcTypeCode != Integer.MIN_VALUE ) {
return typeConfiguration.getJdbcTypeRegistry().getDescriptor( jdbcTypeCode );
}
@ -580,10 +579,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
};
explicitJavaTypeAccess = typeConfiguration -> {
final AnnotationUsage<MapKeyJavaType> javaTypeAnn = attributeMember.locateAnnotationUsage( MapKeyJavaType.class );
final MapKeyJavaType javaTypeAnn = attributeMember.locateAnnotationUsage( MapKeyJavaType.class, getSourceModelContext() );
if ( javaTypeAnn != null ) {
final ClassDetails implDetails = javaTypeAnn.getClassDetails( "value" );
final Class<? extends BasicJavaType<?>> javaTypeClass = normalizeJavaType( implDetails.toJavaClass() );
final Class<? extends BasicJavaType<?>> javaTypeClass = javaTypeAnn.value();
if ( javaTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass );
@ -592,19 +590,18 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<MapKeyClass> mapKeyClassAnn = attributeMember.getAnnotationUsage( MapKeyClass.class );
final MapKeyClass mapKeyClassAnn = attributeMember.getDirectAnnotationUsage( MapKeyClass.class );
if ( mapKeyClassAnn != null ) {
final ClassDetails mapKeyClassDetails = mapKeyClassAnn.getClassDetails( "value" );
return (BasicJavaType<?>) typeConfiguration.getJavaTypeRegistry().getDescriptor( mapKeyClassDetails.toJavaClass() );
return (BasicJavaType<?>) typeConfiguration.getJavaTypeRegistry().getDescriptor( mapKeyClassAnn.value() );
}
return null;
};
explicitMutabilityAccess = typeConfiguration -> {
final AnnotationUsage<MapKeyMutability> mutabilityAnn = attributeMember.locateAnnotationUsage( MapKeyMutability.class );
final MapKeyMutability mutabilityAnn = attributeMember.locateAnnotationUsage( MapKeyMutability.class, getSourceModelContext() );
if ( mutabilityAnn != null ) {
final Class<? extends MutabilityPlan<?>> mutabilityClass = mutabilityAnn.getClassDetails( "value" ).toJavaClass();
final Class<? extends MutabilityPlan<?>> mutabilityClass = mutabilityAnn.value();
if ( mutabilityClass != null ) {
return resolveMutability( mutabilityClass );
}
@ -638,7 +635,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
// if there is a UserType, see if its Class is annotated with mutability-related annotations
final Class<? extends UserType<?>> customTypeImpl = Kind.MAP_KEY.mappingAccess.customType( attributeMember );
final Class<? extends UserType<?>> customTypeImpl = Kind.MAP_KEY.mappingAccess.customType( attributeMember, getSourceModelContext() );
if ( customTypeImpl != null ) {
final Mutability customTypeMutabilityAnn = customTypeImpl.getAnnotation( Mutability.class );
if ( customTypeMutabilityAnn != null ) {
@ -664,10 +661,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
.requireService( ManagedBeanRegistry.class );
explicitJavaTypeAccess = (typeConfiguration) -> {
final AnnotationUsage<ListIndexJavaType> javaTypeAnn = attributeMember.locateAnnotationUsage( ListIndexJavaType.class );
final ListIndexJavaType javaTypeAnn = attributeMember.locateAnnotationUsage( ListIndexJavaType.class, getSourceModelContext() );
if ( javaTypeAnn != null ) {
final ClassDetails implDetails = javaTypeAnn.getClassDetails( "value" );
final Class<? extends BasicJavaType<?>> javaTypeClass = normalizeJavaType( implDetails.toJavaClass() );
final Class<? extends BasicJavaType<?>> javaTypeClass = javaTypeAnn.value();
if ( javaTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass );
@ -681,10 +677,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
};
explicitJdbcTypeAccess = (typeConfiguration) -> {
final AnnotationUsage<ListIndexJdbcType> jdbcTypeAnn = attributeMember.locateAnnotationUsage( ListIndexJdbcType.class );
final ListIndexJdbcType jdbcTypeAnn = attributeMember.locateAnnotationUsage( ListIndexJdbcType.class, getSourceModelContext() );
if ( jdbcTypeAnn != null ) {
final ClassDetails implDetails = jdbcTypeAnn.getClassDetails( "value" );
final Class<? extends JdbcType> jdbcTypeClass = normalizeJdbcType( implDetails.toJavaClass() );
final Class<? extends JdbcType> jdbcTypeClass = jdbcTypeAnn.value();
if ( jdbcTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass );
@ -694,9 +689,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<ListIndexJdbcTypeCode> jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( ListIndexJdbcTypeCode.class );
final ListIndexJdbcTypeCode jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( ListIndexJdbcTypeCode.class, getSourceModelContext() );
if ( jdbcTypeCodeAnn != null ) {
return typeConfiguration.getJdbcTypeRegistry().getDescriptor( jdbcTypeCodeAnn.getInteger( "value" ) );
return typeConfiguration.getJdbcTypeRegistry().getDescriptor( jdbcTypeCodeAnn.value() );
}
return null;
@ -715,10 +710,10 @@ public class BasicValueBinder implements JdbcTypeIndicators {
implicitJavaTypeAccess = typeConfiguration -> javaType;
final AnnotationUsage<Temporal> temporalAnn = attributeMember.getAnnotationUsage( Temporal.class );
final Temporal temporalAnn = attributeMember.getDirectAnnotationUsage( Temporal.class );
if ( temporalAnn != null ) {
DEPRECATION_LOGGER.deprecatedAnnotation( Temporal.class, attributeMember.getName() );
temporalPrecision = temporalAnn.getEnum( "value" );
temporalPrecision = temporalAnn.value();
if ( temporalPrecision == null ) {
throw new IllegalStateException(
"No jakarta.persistence.TemporalType defined for @jakarta.persistence.Temporal " +
@ -731,9 +726,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
if ( javaTypeClass.isEnum() ) {
final AnnotationUsage<Enumerated> enumeratedAnn = attributeMember.getAnnotationUsage( Enumerated.class );
final Enumerated enumeratedAnn = attributeMember.getDirectAnnotationUsage( Enumerated.class );
if ( enumeratedAnn != null ) {
enumType = enumeratedAnn.getEnum( "value" );
enumType = enumeratedAnn.value();
if ( enumType == null ) {
throw new IllegalStateException(
"jakarta.persistence.EnumType was null on @jakarta.persistence.Enumerated " +
@ -749,10 +744,10 @@ public class BasicValueBinder implements JdbcTypeIndicators {
normalSupplementalDetails( attributeMember);
// layer in support for JPA's approach for specifying a specific Java type for the collection elements...
final AnnotationUsage<ElementCollection> elementCollectionAnn = attributeMember.getAnnotationUsage( ElementCollection.class );
final ElementCollection elementCollectionAnn = attributeMember.getDirectAnnotationUsage( ElementCollection.class );
if ( elementCollectionAnn != null ) {
final ClassDetails targetClassDetails = elementCollectionAnn.getClassDetails( "targetClass" );
if ( ClassDetails.VOID_CLASS_DETAILS != targetClassDetails ) {
final Class<?> targetClassDetails = elementCollectionAnn.targetClass();
if ( targetClassDetails != void.class) {
//noinspection rawtypes
final Function<TypeConfiguration, BasicJavaType> original = explicitJavaTypeAccess;
explicitJavaTypeAccess = (typeConfiguration) -> {
@ -763,7 +758,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
return (BasicJavaType<?>) typeConfiguration
.getJavaTypeRegistry()
.getDescriptor( targetClassDetails.toJavaClass() );
.getDescriptor( targetClassDetails );
};
}
}
@ -782,11 +777,11 @@ public class BasicValueBinder implements JdbcTypeIndicators {
} );
//noinspection deprecation
final var temporalAnn = attributeMember.getAnnotationUsage( Temporal.class );
final var temporalAnn = attributeMember.getDirectAnnotationUsage( Temporal.class );
if ( temporalAnn != null ) {
//noinspection deprecation
DEPRECATION_LOGGER.deprecatedAnnotation( Temporal.class, declaringClassName + "." + attributeMember.getName() );
this.temporalPrecision = temporalAnn.getEnum( "value" );
this.temporalPrecision = temporalAnn.value();
if ( this.temporalPrecision == null ) {
throw new IllegalStateException(
"No jakarta.persistence.TemporalType defined for @jakarta.persistence.Temporal " +
@ -798,9 +793,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
this.temporalPrecision = null;
}
final AnnotationUsage<Enumerated> enumeratedAnn = attributeMember.getAnnotationUsage( Enumerated.class );
final Enumerated enumeratedAnn = attributeMember.getDirectAnnotationUsage( Enumerated.class );
if ( enumeratedAnn != null ) {
this.enumType = enumeratedAnn.getEnum( "value" );
this.enumType = enumeratedAnn.value();
if ( canUseEnumerated( attributeType, javaTypeClass ) ) {
if ( this.enumType == null ) {
throw new IllegalStateException(
@ -842,12 +837,12 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
private void prepareAnyDiscriminator(MemberDetails memberDetails) {
final AnnotationUsage<AnyDiscriminator> anyDiscriminatorAnn = memberDetails.locateAnnotationUsage( AnyDiscriminator.class );
final AnyDiscriminator anyDiscriminatorAnn = memberDetails.locateAnnotationUsage( AnyDiscriminator.class, getSourceModelContext() );
implicitJavaTypeAccess = (typeConfiguration) -> {
if ( anyDiscriminatorAnn != null ) {
final DiscriminatorType anyDiscriminatorType = anyDiscriminatorAnn.getEnum( "value" );
return switch ( anyDiscriminatorAnn.getEnum( "value", DiscriminatorType.class ) ) {
final DiscriminatorType anyDiscriminatorType = anyDiscriminatorAnn.value();
return switch ( anyDiscriminatorType ) {
case CHAR -> Character.class;
case INTEGER -> Integer.class;
default -> String.class;
@ -882,10 +877,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi();
explicitJavaTypeAccess = (typeConfiguration) -> {
final AnnotationUsage<AnyKeyJavaType> javaTypeAnn = memberDetails.locateAnnotationUsage( AnyKeyJavaType.class );
final AnyKeyJavaType javaTypeAnn = memberDetails.locateAnnotationUsage( AnyKeyJavaType.class, getSourceModelContext() );
if ( javaTypeAnn != null ) {
final ClassDetails implDetails = javaTypeAnn.getClassDetails( "value" );
final Class<? extends BasicJavaType<?>> implClass = normalizeJavaType( implDetails.toJavaClass() );
final Class<? extends BasicJavaType<?>> implClass = javaTypeAnn.value();
if ( implClass != null ) {
if ( useDeferredBeanContainerAccess ) {
@ -895,23 +889,22 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<AnyKeyJavaClass> javaClassAnn = memberDetails.locateAnnotationUsage( AnyKeyJavaClass.class );
final AnyKeyJavaClass javaClassAnn = memberDetails.locateAnnotationUsage( AnyKeyJavaClass.class, getSourceModelContext() );
if ( javaClassAnn != null ) {
final ClassDetails implDetails = javaClassAnn.getClassDetails( "value" );
final Class<?> impl = javaClassAnn.value();
//noinspection rawtypes
return (BasicJavaType) typeConfiguration
.getJavaTypeRegistry()
.getDescriptor( implDetails.toJavaClass() );
.getDescriptor( impl );
}
throw new MappingException("Could not determine key type for '@Any' mapping (specify '@AnyKeyJavaType' or '@AnyKeyJavaClass')");
};
explicitJdbcTypeAccess = (typeConfiguration) -> {
final AnnotationUsage<AnyKeyJdbcType> jdbcTypeAnn = memberDetails.locateAnnotationUsage( AnyKeyJdbcType.class );
final AnyKeyJdbcType jdbcTypeAnn = memberDetails.locateAnnotationUsage( AnyKeyJdbcType.class, getSourceModelContext() );
if ( jdbcTypeAnn != null ) {
final ClassDetails implDetails = jdbcTypeAnn.getClassDetails( "value" );
final Class<? extends JdbcType> jdbcTypeClass = normalizeJdbcType( implDetails.toJavaClass() );
final Class<? extends JdbcType> jdbcTypeClass = jdbcTypeAnn.value();
if ( jdbcTypeClass != null ) {
if ( useDeferredBeanContainerAccess ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass );
@ -921,9 +914,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<AnyKeyJdbcTypeCode> jdbcTypeCodeAnn = memberDetails.locateAnnotationUsage( AnyKeyJdbcTypeCode.class );
final AnyKeyJdbcTypeCode jdbcTypeCodeAnn = memberDetails.locateAnnotationUsage( AnyKeyJdbcTypeCode.class, getSourceModelContext() );
if ( jdbcTypeCodeAnn != null ) {
final int code = jdbcTypeCodeAnn.getInteger( "value" );
final int code = jdbcTypeCodeAnn.value();
if ( code != Integer.MIN_VALUE ) {
return typeConfiguration.getJdbcTypeRegistry().getDescriptor( code );
}
@ -935,9 +928,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
private void normalJdbcTypeDetails(MemberDetails attributeMember) {
explicitJdbcTypeAccess = typeConfiguration -> {
final AnnotationUsage<org.hibernate.annotations.JdbcType> jdbcTypeAnn = attributeMember.locateAnnotationUsage( org.hibernate.annotations.JdbcType.class );
final org.hibernate.annotations.JdbcType jdbcTypeAnn = attributeMember.locateAnnotationUsage( org.hibernate.annotations.JdbcType.class, getSourceModelContext() );
if ( jdbcTypeAnn != null ) {
final Class<? extends JdbcType> jdbcTypeClass = normalizeJdbcType( jdbcTypeAnn.getClassDetails( "value" ).toJavaClass() );
final Class<? extends JdbcType> jdbcTypeClass = jdbcTypeAnn.value();
if ( jdbcTypeClass != null ) {
if ( !buildingContext.getBuildingOptions().isAllowExtensionsInCdi() ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass );
@ -946,9 +939,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
final AnnotationUsage<JdbcTypeCode> jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( JdbcTypeCode.class );
final JdbcTypeCode jdbcTypeCodeAnn = attributeMember.locateAnnotationUsage( JdbcTypeCode.class, getSourceModelContext() );
if ( jdbcTypeCodeAnn != null ) {
final int jdbcTypeCode = jdbcTypeCodeAnn.getInteger( "value" );
final int jdbcTypeCode = jdbcTypeCodeAnn.value();
if ( jdbcTypeCode != Integer.MIN_VALUE ) {
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry();
if ( jdbcTypeRegistry.getConstructor( jdbcTypeCode ) != null ) {
@ -967,16 +960,16 @@ public class BasicValueBinder implements JdbcTypeIndicators {
private void normalMutabilityDetails(MemberDetails attributeMember) {
explicitMutabilityAccess = typeConfiguration -> {
// Look for `@Mutability` on the attribute
final AnnotationUsage<Mutability> mutabilityAnn = attributeMember.locateAnnotationUsage( Mutability.class );
final Mutability mutabilityAnn = attributeMember.locateAnnotationUsage( Mutability.class, getSourceModelContext() );
if ( mutabilityAnn != null ) {
final Class<? extends MutabilityPlan<?>> mutability = mutabilityAnn.getClassDetails( "value" ).toJavaClass();
final Class<? extends MutabilityPlan<?>> mutability = mutabilityAnn.value();
if ( mutability != null ) {
return resolveMutability( mutability );
}
}
// Look for `@Immutable` on the attribute
if ( attributeMember.hasAnnotationUsage( Immutable.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( Immutable.class ) ) {
return ImmutableMutabilityPlan.instance();
}
@ -1028,7 +1021,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
// if a custom UserType is specified, see if the UserType Class is annotated `@Mutability`
final Class<? extends UserType<?>> customTypeImpl = Kind.ATTRIBUTE.mappingAccess.customType( attributeMember );
final Class<? extends UserType<?>> customTypeImpl = Kind.ATTRIBUTE.mappingAccess.customType( attributeMember, getSourceModelContext() );
if ( customTypeImpl != null ) {
final Mutability customTypeMutabilityAnn = customTypeImpl.getAnnotation( Mutability.class );
if ( customTypeMutabilityAnn != null ) {
@ -1066,9 +1059,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
private void normalSupplementalDetails(MemberDetails attributeMember) {
explicitJavaTypeAccess = typeConfiguration -> {
final AnnotationUsage<org.hibernate.annotations.JavaType> javaType = attributeMember.locateAnnotationUsage( org.hibernate.annotations.JavaType.class );
final org.hibernate.annotations.JavaType javaType = attributeMember.locateAnnotationUsage( org.hibernate.annotations.JavaType.class, getSourceModelContext() );
if ( javaType != null ) {
final Class<? extends BasicJavaType<?>> javaTypeClass = normalizeJavaType( javaType.getClassDetails( "value" ).toJavaClass() );
final Class<? extends BasicJavaType<?>> javaTypeClass = normalizeJavaType( javaType.value() );
if ( javaTypeClass != null ) {
if ( !buildingContext.getBuildingOptions().isAllowExtensionsInCdi() ) {
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass );
@ -1078,38 +1071,38 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
//noinspection deprecation
final var targetAnn = attributeMember.locateAnnotationUsage( Target.class );
final var targetAnn = attributeMember.locateAnnotationUsage( Target.class, getSourceModelContext() );
if ( targetAnn != null ) {
//noinspection deprecation
DEPRECATION_LOGGER.deprecatedAnnotation( Target.class, attributeMember.getName() );
return (BasicJavaType<?>) typeConfiguration.getJavaTypeRegistry().getDescriptor( targetAnn.getClassDetails( "value" ).toJavaClass() );
return (BasicJavaType<?>) typeConfiguration.getJavaTypeRegistry().getDescriptor( targetAnn.value() );
}
return null;
};
final AnnotationUsage<JdbcTypeCode> jdbcType = attributeMember.locateAnnotationUsage( JdbcTypeCode.class );
final JdbcTypeCode jdbcType = attributeMember.locateAnnotationUsage( JdbcTypeCode.class, getSourceModelContext() );
if ( jdbcType != null ) {
jdbcTypeCode = jdbcType.getInteger( "value" );
jdbcTypeCode = jdbcType.value();
}
normalJdbcTypeDetails( attributeMember);
normalMutabilityDetails( attributeMember );
final AnnotationUsage<Enumerated> enumerated = attributeMember.getAnnotationUsage( Enumerated.class );
final Enumerated enumerated = attributeMember.getDirectAnnotationUsage( Enumerated.class );
if ( enumerated != null ) {
enumType = enumerated.getEnum( "value" );
enumType = enumerated.value();
}
final AnnotationUsage<Temporal> temporal = attributeMember.getAnnotationUsage( Temporal.class );
final Temporal temporal = attributeMember.getDirectAnnotationUsage( Temporal.class );
if ( temporal != null ) {
temporalPrecision = temporal.getEnum( "value" );
temporalPrecision = temporal.value();
}
final AnnotationUsage<TimeZoneStorage> timeZoneStorage = attributeMember.getAnnotationUsage( TimeZoneStorage.class );
final TimeZoneStorage timeZoneStorage = attributeMember.getDirectAnnotationUsage( TimeZoneStorage.class );
if ( timeZoneStorage != null ) {
timeZoneStorageType = timeZoneStorage.getEnum( "value" );
final AnnotationUsage<TimeZoneColumn> timeZoneColumnAnn = attributeMember.getAnnotationUsage( TimeZoneColumn.class );
timeZoneStorageType = timeZoneStorage.value();
final TimeZoneColumn timeZoneColumnAnn = attributeMember.getDirectAnnotationUsage( TimeZoneColumn.class );
if ( timeZoneColumnAnn != null ) {
if ( timeZoneStorageType != TimeZoneStorageType.AUTO && timeZoneStorageType != TimeZoneStorageType.COLUMN ) {
throw new IllegalStateException(
@ -1121,7 +1114,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
}
}
this.partitionKey = attributeMember.hasAnnotationUsage( PartitionKey.class );
this.partitionKey = attributeMember.hasDirectAnnotationUsage( PartitionKey.class );
}
private static Class<? extends UserType<?>> normalizeUserType(Class<? extends UserType<?>> userType) {
@ -1148,34 +1141,34 @@ public class BasicValueBinder implements JdbcTypeIndicators {
LOG.debugf( "Applying JPA converter [%s:%s]", persistentClassName, attributeMember.getName() );
if ( attributeMember.hasAnnotationUsage( Id.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( Id.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for Id attribute [%s]", attributeMember.getName() );
return;
}
if ( attributeMember.hasAnnotationUsage( Version.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( Version.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for version attribute [%s]", attributeMember.getName() );
return;
}
if ( kind == Kind.MAP_KEY ) {
if ( attributeMember.hasAnnotationUsage( MapKeyTemporal.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( MapKeyTemporal.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyTemporal [%s]", attributeMember.getName() );
return;
}
if ( attributeMember.hasAnnotationUsage( MapKeyEnumerated.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( MapKeyEnumerated.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyEnumerated [%s]", attributeMember.getName() );
return;
}
}
else {
if ( attributeMember.hasAnnotationUsage( Temporal.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( Temporal.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for Temporal attribute [%s]", attributeMember.getName() );
return;
}
if ( attributeMember.hasAnnotationUsage( Enumerated.class ) ) {
if ( attributeMember.hasDirectAnnotationUsage( Enumerated.class ) ) {
LOG.debugf( "Skipping AttributeConverter checks for Enumerated attribute [%s]", attributeMember.getName() );
return;
}
@ -1454,31 +1447,31 @@ public class BasicValueBinder implements JdbcTypeIndicators {
* Access to detail of basic value mappings based on {@link Kind}
*/
private interface BasicMappingAccess {
Class<? extends UserType<?>> customType(MemberDetails attributeMember);
Map<String,String> customTypeParameters(MemberDetails attributeMember);
Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext);
Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext);
}
private static class ValueMappingAccess implements BasicMappingAccess {
public static final ValueMappingAccess INSTANCE = new ValueMappingAccess();
@Override
public Class<? extends UserType<?>> customType(MemberDetails attributeMember) {
final AnnotationUsage<Type> customType = attributeMember.locateAnnotationUsage( Type.class );
public Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
final Type customType = attributeMember.locateAnnotationUsage( Type.class, sourceModelContext );
if ( customType == null ) {
return null;
}
return normalizeUserType( customType.getClassDetails( "value" ).toJavaClass() );
return normalizeUserType( customType.value() );
}
@Override
public Map<String,String> customTypeParameters(MemberDetails attributeMember) {
final AnnotationUsage<Type> customType = attributeMember.locateAnnotationUsage( Type.class );
public Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
final Type customType = attributeMember.locateAnnotationUsage( Type.class, sourceModelContext );
if ( customType == null ) {
return null;
}
return AnnotationHelper.extractParameterMap( customType.getList( "parameters" ) );
return AnnotationHelper.extractParameterMap( customType.parameters() );
}
}
@ -1486,12 +1479,12 @@ public class BasicValueBinder implements JdbcTypeIndicators {
public static final AnyDiscriminatorMappingAccess INSTANCE = new AnyDiscriminatorMappingAccess();
@Override
public Class<? extends UserType<?>> customType(MemberDetails attributeMember) {
public Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
return null;
}
@Override
public Map<String,String> customTypeParameters(MemberDetails attributeMember) {
public Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
return Collections.emptyMap();
}
}
@ -1500,12 +1493,12 @@ public class BasicValueBinder implements JdbcTypeIndicators {
public static final AnyKeyMappingAccess INSTANCE = new AnyKeyMappingAccess();
@Override
public Class<? extends UserType<?>> customType(MemberDetails attributeMember) {
public Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
return null;
}
@Override
public Map<String,String> customTypeParameters(MemberDetails attributeMember) {
public Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
return Collections.emptyMap();
}
}
@ -1514,23 +1507,23 @@ public class BasicValueBinder implements JdbcTypeIndicators {
public static final MapKeyMappingAccess INSTANCE = new MapKeyMappingAccess();
@Override
public Class<? extends UserType<?>> customType(MemberDetails attributeMember) {
final AnnotationUsage<MapKeyType> customType = attributeMember.locateAnnotationUsage( MapKeyType.class );
public Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
final MapKeyType customType = attributeMember.locateAnnotationUsage( MapKeyType.class, sourceModelContext );
if ( customType == null ) {
return null;
}
return normalizeUserType( customType.getClassDetails( "value" ).toJavaClass() );
return normalizeUserType( customType.value() );
}
@Override
public Map<String,String> customTypeParameters(MemberDetails attributeMember) {
final AnnotationUsage<MapKeyType> customType = attributeMember.locateAnnotationUsage( MapKeyType.class );
public Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
final MapKeyType customType = attributeMember.locateAnnotationUsage( MapKeyType.class, sourceModelContext );
if ( customType == null ) {
return null;
}
return AnnotationHelper.extractParameterMap( customType.getList( "parameters" ) );
return AnnotationHelper.extractParameterMap( customType.parameters() );
}
}
@ -1538,23 +1531,23 @@ public class BasicValueBinder implements JdbcTypeIndicators {
public static final CollectionIdMappingAccess INSTANCE = new CollectionIdMappingAccess();
@Override
public Class<? extends UserType<?>> customType(MemberDetails attributeMember) {
final AnnotationUsage<CollectionIdType> customType = attributeMember.locateAnnotationUsage( CollectionIdType.class );
public Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelBuildingContext) {
final CollectionIdType customType = attributeMember.locateAnnotationUsage( CollectionIdType.class, sourceModelBuildingContext );
if ( customType == null ) {
return null;
}
return normalizeUserType( customType.getClassDetails( "value" ).toJavaClass() );
return normalizeUserType( customType.value() );
}
@Override
public Map<String,String> customTypeParameters(MemberDetails attributeMember) {
final AnnotationUsage<CollectionIdType> customType = attributeMember.locateAnnotationUsage( CollectionIdType.class );
public Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
final CollectionIdType customType = attributeMember.locateAnnotationUsage( CollectionIdType.class, sourceModelContext );
if ( customType == null ) {
return null;
}
return AnnotationHelper.extractParameterMap( customType.getList( "parameters" ) );
return AnnotationHelper.extractParameterMap( customType.parameters() );
}
}
@ -1562,12 +1555,12 @@ public class BasicValueBinder implements JdbcTypeIndicators {
public static final ListIndexMappingAccess INSTANCE = new ListIndexMappingAccess();
@Override
public Class<? extends UserType<?>> customType(MemberDetails attributeMember) {
public Class<? extends UserType<?>> customType(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
return null;
}
@Override
public Map<String,String> customTypeParameters(MemberDetails attributeMember) {
public Map<String,String> customTypeParameters(MemberDetails attributeMember, SourceModelBuildingContext sourceModelContext) {
return Collections.emptyMap();
}
}

View File

@ -8,6 +8,7 @@ package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashSet;
@ -35,6 +36,7 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.AttributeContainer;
import org.hibernate.mapping.BasicValue;
@ -51,10 +53,10 @@ import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeDetailsHelper;
import org.hibernate.type.descriptor.java.JavaType;
@ -746,8 +748,8 @@ public class BinderHelper {
}
public static Any buildAnyValue(
AnnotationUsage<jakarta.persistence.Column> discriminatorColumn,
AnnotationUsage<Formula> discriminatorFormula,
jakarta.persistence.Column discriminatorColumn,
Formula discriminatorFormula,
AnnotatedJoinColumns keyColumns,
PropertyData inferredData,
OnDeleteAction onDeleteAction,
@ -802,9 +804,10 @@ public class BinderHelper {
processAnyDiscriminatorValues(
inferredData.getAttributeMember(),
valueMapping -> discriminatorValueMappings.put(
discriminatorJavaType.wrap( valueMapping.getString( "discriminator" ), null ),
valueMapping.getClassDetails( "entity" ).toJavaClass()
)
discriminatorJavaType.wrap( valueMapping.discriminator(), null ),
valueMapping.entity()
),
context.getMetadataCollector().getSourceModelBuildingContext()
);
value.setDiscriminatorValueMappings( discriminatorValueMappings );
@ -829,15 +832,16 @@ public class BinderHelper {
private static void processAnyDiscriminatorValues(
MemberDetails property,
Consumer<AnnotationUsage<AnyDiscriminatorValue>> consumer) {
final AnnotationUsage<AnyDiscriminatorValues> valuesAnn = property.locateAnnotationUsage( AnyDiscriminatorValues.class );
Consumer<AnyDiscriminatorValue> consumer,
SourceModelBuildingContext sourceModelContext) {
final AnyDiscriminatorValues valuesAnn = property.locateAnnotationUsage( AnyDiscriminatorValues.class, sourceModelContext );
if ( valuesAnn != null ) {
final List<AnnotationUsage<AnyDiscriminatorValue>> nestedList = valuesAnn.getList( "value" );
nestedList.forEach( consumer );
final AnyDiscriminatorValue[] nestedList = valuesAnn.value();
ArrayHelper.forEach( nestedList, consumer );
return;
}
final AnnotationUsage<AnyDiscriminatorValue> valueAnn = property.locateAnnotationUsage( AnyDiscriminatorValue.class );
final AnyDiscriminatorValue valueAnn = property.locateAnnotationUsage( AnyDiscriminatorValue.class, sourceModelContext );
if ( valueAnn != null ) {
consumer.accept( valueAnn );
}
@ -898,31 +902,31 @@ public class BinderHelper {
return metadataCollector.getPropertyAnnotatedWithMapsId( classDetails, isId ? "" : propertyName );
}
public static Map<String,String> toAliasTableMap(List<AnnotationUsage<SqlFragmentAlias>> aliases){
public static Map<String,String> toAliasTableMap(SqlFragmentAlias[] aliases){
final Map<String,String> ret = new HashMap<>();
for ( AnnotationUsage<SqlFragmentAlias> aliasAnnotation : aliases ) {
final String table = aliasAnnotation.getString( "table" );
for ( SqlFragmentAlias aliasAnnotation : aliases ) {
final String table = aliasAnnotation.table();
if ( isNotEmpty( table ) ) {
ret.put( aliasAnnotation.getString( "alias" ), table );
ret.put( aliasAnnotation.alias(), table );
}
}
return ret;
}
public static Map<String,String> toAliasEntityMap(List<AnnotationUsage<SqlFragmentAlias>> aliases){
public static Map<String,String> toAliasEntityMap(SqlFragmentAlias[] aliases){
final Map<String,String> result = new HashMap<>();
for ( AnnotationUsage<SqlFragmentAlias> aliasAnnotation : aliases ) {
final ClassDetails entityClassDetails = aliasAnnotation.getClassDetails( "entity" );
if ( entityClassDetails != ClassDetails.VOID_CLASS_DETAILS ) {
result.put( aliasAnnotation.getString( "alias" ), entityClassDetails.getName() );
for ( SqlFragmentAlias aliasAnnotation : aliases ) {
final Class<?> entityClass = aliasAnnotation.entity();
if ( entityClass != void.class ) {
result.put( aliasAnnotation.alias(), entityClass.getName() );
}
}
return result;
}
public static boolean hasToOneAnnotation(AnnotationTarget property) {
return property.hasAnnotationUsage(ManyToOne.class)
|| property.hasAnnotationUsage(OneToOne.class);
return property.hasDirectAnnotationUsage(ManyToOne.class)
|| property.hasDirectAnnotationUsage(OneToOne.class);
}
@ -934,16 +938,16 @@ public class BinderHelper {
}
public static String getCascadeStrategy(
List<jakarta.persistence.CascadeType> ejbCascades,
AnnotationUsage<Cascade> hibernateCascadeAnnotation,
jakarta.persistence.CascadeType[] ejbCascades,
Cascade hibernateCascadeAnnotation,
boolean orphanRemoval,
MetadataBuildingContext context) {
final EnumSet<CascadeType> cascadeTypes = convertToHibernateCascadeType( ejbCascades );
final List<CascadeType> hibernateCascades = hibernateCascadeAnnotation == null
final CascadeType[] hibernateCascades = hibernateCascadeAnnotation == null
? null
: hibernateCascadeAnnotation.getList( "value" );
if ( hibernateCascades != null && !hibernateCascades.isEmpty() ) {
cascadeTypes.addAll( hibernateCascades );
: hibernateCascadeAnnotation.value();
if ( !ArrayHelper.isEmpty( hibernateCascades ) ) {
Collections.addAll( cascadeTypes, hibernateCascades );
}
if ( orphanRemoval ) {
cascadeTypes.add( CascadeType.DELETE_ORPHAN );
@ -953,7 +957,7 @@ public class BinderHelper {
return renderCascadeTypeList( cascadeTypes );
}
private static EnumSet<CascadeType> convertToHibernateCascadeType(List<jakarta.persistence.CascadeType> ejbCascades) {
private static EnumSet<CascadeType> convertToHibernateCascadeType(jakarta.persistence.CascadeType[] ejbCascades) {
final EnumSet<CascadeType> cascadeTypes = EnumSet.noneOf( CascadeType.class );
if ( ejbCascades != null ) {
for ( jakarta.persistence.CascadeType cascade: ejbCascades ) {
@ -1050,8 +1054,8 @@ public class BinderHelper {
}
static boolean isCompositeId(ClassDetails entityClass, MemberDetails idProperty) {
return entityClass.hasAnnotationUsage( Embeddable.class )
|| idProperty.hasAnnotationUsage( EmbeddedId.class );
return entityClass.hasDirectAnnotationUsage( Embeddable.class )
|| idProperty.hasDirectAnnotationUsage( EmbeddedId.class );
}
public static boolean isDefault(ClassDetails clazz, MetadataBuildingContext context) {
@ -1110,12 +1114,12 @@ public class BinderHelper {
return false;
}
public static boolean noConstraint(AnnotationUsage<ForeignKey> foreignKey, boolean noConstraintByDefault) {
public static boolean noConstraint(ForeignKey foreignKey, boolean noConstraintByDefault) {
if ( foreignKey == null ) {
return false;
}
else {
final ConstraintMode mode = foreignKey.getEnum( "value" );
final ConstraintMode mode = foreignKey.value();
return mode == NO_CONSTRAINT
|| mode == PROVIDER_DEFAULT && noConstraintByDefault;
}
@ -1130,7 +1134,7 @@ public class BinderHelper {
*
* @return The annotation or {@code null}
*/
public static <A extends Annotation> AnnotationUsage<A> extractFromPackage(
public static <A extends Annotation> A extractFromPackage(
Class<A> annotationType,
ClassDetails classDetails,
MetadataBuildingContext context) {
@ -1148,14 +1152,13 @@ public class BinderHelper {
if ( isEmpty( packageName ) ) {
return null;
}
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final ClassDetailsRegistry classDetailsRegistry = sourceModelContext.getClassDetailsRegistry();
final ClassDetailsRegistry classDetailsRegistry = context.getMetadataCollector()
.getSourceModelBuildingContext()
.getClassDetailsRegistry();
final String packageInfoName = packageName + ".package-info";
try {
final ClassDetails packageInfoClassDetails = classDetailsRegistry.resolveClassDetails( packageInfoName );
return packageInfoClassDetails.getAnnotationUsage( annotationType );
return packageInfoClassDetails.getAnnotationUsage( annotationType, sourceModelContext );
}
catch (ClassLoadingException ignore) {
}

View File

@ -6,13 +6,11 @@
*/
package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
@ -32,10 +30,8 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails;
import jakarta.persistence.Convert;
import jakarta.persistence.JoinTable;
@ -104,14 +100,14 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
// collect superclass info first
collectAttributeConversionInfo( infoMap, entityClassDetails.getSuperClass() );
final boolean canContainConvert = entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class );
final boolean canContainConvert = entityClassDetails.hasAnnotationUsage( jakarta.persistence.Entity.class, getSourceModelContext() )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class, getSourceModelContext() )
|| entityClassDetails.hasAnnotationUsage( jakarta.persistence.Embeddable.class, getSourceModelContext() );
if ( ! canContainConvert ) {
return;
}
entityClassDetails.forEachAnnotationUsage( Convert.class, (usage) -> {
entityClassDetails.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
final AttributeConversionInfo info = new AttributeConversionInfo( usage, entityClassDetails );
if ( isEmpty( info.getAttributeName() ) ) {
throw new IllegalStateException( "@Convert placed on @Entity/@MappedSuperclass must define attributeName" );
@ -131,7 +127,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
return;
}
property.forEachAnnotationUsage( Convert.class, (usage) -> {
property.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
final AttributeConversionInfo info = new AttributeConversionInfo( usage, property );
if ( isEmpty( info.getAttributeName() ) ) {
attributeConversionInfoMap.put( propertyName, info );
@ -192,19 +188,19 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
}
@Override
public Join addJoin(AnnotationUsage<JoinTable> joinTableAnn, boolean noDelayInPkColumnCreation) {
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
final Join join = entityBinder.addJoinTable( joinTableAnn, this, noDelayInPkColumnCreation );
joins = entityBinder.getSecondaryTables();
return join;
}
@Override
public Join addJoin(AnnotationUsage<JoinTable> joinTable, Table table, boolean noDelayInPkColumnCreation) {
public Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation) {
final Join join = entityBinder.createJoin(
this,
noDelayInPkColumnCreation,
false,
joinTable.getList( "joinColumns" ),
joinTable.joinColumns(),
table.getQualifiedTableName(),
table
);

View File

@ -24,7 +24,6 @@ import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails;
@ -87,7 +86,7 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
return;
}
collectionProperty.forEachAnnotationUsage( Convert.class, (usage) -> {
collectionProperty.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
applyLocalConvert(
usage,
collectionProperty,
@ -99,7 +98,7 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
}
private void applyLocalConvert(
AnnotationUsage<Convert> convertAnnotation,
Convert convertAnnotation,
MemberDetails collectionProperty,
boolean isComposite,
Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap,
@ -311,12 +310,12 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
}
@Override
public Join addJoin(AnnotationUsage<JoinTable> joinTableAnn, boolean noDelayInPkColumnCreation) {
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
throw new AssertionFailure( "Add join in a second pass" );
}
@Override
public Join addJoin(AnnotationUsage<JoinTable> joinTableAnn, Table table, boolean noDelayInPkColumnCreation) {
public Join addJoin(JoinTable joinTableAnn, Table table, boolean noDelayInPkColumnCreation) {
throw new AssertionFailure( "Add join in a second pass" );
}
@ -340,16 +339,16 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
prepared = true;
if ( collection.isMap() ) {
if ( collectionProperty.hasAnnotationUsage( MapKeyEnumerated.class ) ) {
if ( collectionProperty.hasDirectAnnotationUsage( MapKeyEnumerated.class ) ) {
canKeyBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( MapKeyTemporal.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( MapKeyTemporal.class ) ) {
canKeyBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( MapKeyClass.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( MapKeyClass.class ) ) {
canKeyBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( MapKeyType.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( MapKeyType.class ) ) {
canKeyBeConverted = false;
}
}
@ -357,22 +356,22 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
canKeyBeConverted = false;
}
if ( collectionProperty.hasAnnotationUsage( ManyToAny.class ) ) {
if ( collectionProperty.hasDirectAnnotationUsage( ManyToAny.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( OneToMany.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( OneToMany.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( ManyToMany.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( ManyToMany.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( Enumerated.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( Enumerated.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( Temporal.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( Temporal.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.hasAnnotationUsage( CollectionType.class ) ) {
else if ( collectionProperty.hasDirectAnnotationUsage( CollectionType.class ) ) {
canElementBeConverted = false;
}

View File

@ -6,28 +6,24 @@
*/
package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.FractionalSeconds;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.annotations.internal.JoinColumnJpaAnnotation;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.MutableAnnotationUsage;
import org.hibernate.models.spi.SourceModelBuildingContext;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinColumns;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
@ -35,16 +31,14 @@ import jakarta.persistence.MapsId;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.PrimaryKeyJoinColumn;
import jakarta.persistence.PrimaryKeyJoinColumns;
import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromAnnotation;
import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromNoAnnotation;
import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnsFromAnnotations;
import static org.hibernate.boot.model.internal.AnnotatedColumn.buildFormulaFromAnnotation;
import static org.hibernate.boot.model.internal.DialectOverridesAnnotationHelper.getOverridableAnnotation;
import static org.hibernate.boot.model.internal.BinderHelper.getPath;
import static org.hibernate.boot.model.internal.BinderHelper.getPropertyOverriddenByMapperOrMapsId;
import static org.hibernate.boot.models.internal.AnnotationUsageHelper.applyAttributeIfSpecified;
import static org.hibernate.boot.model.internal.DialectOverridesAnnotationHelper.getOverridableAnnotation;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
/**
@ -92,13 +86,14 @@ class ColumnsBuilder {
columns = null;
joinColumns = buildExplicitJoinColumns( property, inferredData );
final AnnotationUsage<Column> columnAnn = property.getAnnotationUsage( Column.class );
final AnnotationUsage<Formula> formulaAnn = property.getAnnotationUsage( Formula.class );
final AnnotationUsage<Columns> columnsAnn = property.getAnnotationUsage( Columns.class );
final Column columnAnn = property.getDirectAnnotationUsage( Column.class );
final Columns columnsAnn = property.getDirectAnnotationUsage( Columns.class );
final Formula formulaAnn = property.getDirectAnnotationUsage( Formula.class );
if ( columnAnn != null ) {
columns = buildColumnFromAnnotation(
property.getAnnotationUsage( Column.class ),
property.getAnnotationUsage( FractionalSeconds.class ),
columnAnn,
property.getDirectAnnotationUsage( FractionalSeconds.class ),
// comment,
nullability,
propertyHolder,
@ -119,7 +114,7 @@ class ColumnsBuilder {
}
else if ( columnsAnn != null ) {
columns = buildColumnsFromAnnotations(
columnsAnn.getList( "columns" ),
columnsAnn.columns(),
null,
nullability,
propertyHolder,
@ -131,18 +126,18 @@ class ColumnsBuilder {
//set default values if needed
if ( joinColumns == null
&& ( property.hasAnnotationUsage( ManyToOne.class )
|| property.hasAnnotationUsage( OneToOne.class ) ) ) {
&& ( property.hasDirectAnnotationUsage( ManyToOne.class )
|| property.hasDirectAnnotationUsage( OneToOne.class ) ) ) {
joinColumns = buildDefaultJoinColumnsForToOne( property, inferredData );
}
else if ( joinColumns == null
&& ( property.hasAnnotationUsage( OneToMany.class )
|| property.hasAnnotationUsage( ElementCollection.class ) ) ) {
AnnotationUsage<OneToMany> oneToMany = property.getAnnotationUsage( OneToMany.class );
&& ( property.hasDirectAnnotationUsage( OneToMany.class )
|| property.hasDirectAnnotationUsage( ElementCollection.class ) ) ) {
OneToMany oneToMany = property.getDirectAnnotationUsage( OneToMany.class );
joinColumns = AnnotatedJoinColumns.buildJoinColumns(
null,
// comment,
oneToMany == null ? null : nullIfEmpty( oneToMany.getString( "mappedBy" ) ),
oneToMany == null ? null : nullIfEmpty( oneToMany.mappedBy() ),
entityBinder.getSecondaryTables(),
propertyHolder,
inferredData,
@ -150,14 +145,14 @@ class ColumnsBuilder {
);
}
else if ( joinColumns == null
&& property.hasAnnotationUsage( org.hibernate.annotations.Any.class ) ) {
&& property.hasDirectAnnotationUsage( org.hibernate.annotations.Any.class ) ) {
throw new AnnotationException( "Property '" + getPath( propertyHolder, inferredData )
+ "' is annotated '@Any' and must declare at least one '@JoinColumn'" );
}
if ( columns == null && !property.hasAnnotationUsage( ManyToMany.class ) ) {
if ( columns == null && !property.hasDirectAnnotationUsage( ManyToMany.class ) ) {
//useful for collection of embedded elements
columns = buildColumnFromNoAnnotation(
property.getAnnotationUsage( FractionalSeconds.class ),
property.getDirectAnnotationUsage( FractionalSeconds.class ),
// comment,
nullability,
propertyHolder,
@ -179,11 +174,11 @@ class ColumnsBuilder {
private AnnotatedJoinColumns buildDefaultJoinColumnsForToOne(
MemberDetails property,
PropertyData inferredData) {
final AnnotationUsage<JoinTable> joinTableAnn = propertyHolder.getJoinTable( property );
final JoinTable joinTableAnn = propertyHolder.getJoinTable( property );
// final Comment comment = property.getAnnotation(Comment.class);
if ( joinTableAnn != null ) {
return AnnotatedJoinColumns.buildJoinColumns(
joinTableAnn.getList( "inverseJoinColumns" ),
joinTableAnn.inverseJoinColumns(),
// comment,
null,
entityBinder.getSecondaryTables(),
@ -193,11 +188,11 @@ class ColumnsBuilder {
);
}
else {
final AnnotationUsage<OneToOne> oneToOneAnn = property.getAnnotationUsage( OneToOne.class );
final OneToOne oneToOneAnn = property.getDirectAnnotationUsage( OneToOne.class );
return AnnotatedJoinColumns.buildJoinColumns(
null,
// comment,
oneToOneAnn == null ? null : nullIfEmpty( oneToOneAnn.getString( "mappedBy" ) ),
oneToOneAnn == null ? null : nullIfEmpty( oneToOneAnn.mappedBy() ),
entityBinder.getSecondaryTables(),
propertyHolder,
inferredData,
@ -208,7 +203,7 @@ class ColumnsBuilder {
private AnnotatedJoinColumns buildExplicitJoinColumns(MemberDetails property, PropertyData inferredData) {
// process @JoinColumns before @Columns to handle collection of entities properly
final List<AnnotationUsage<JoinColumn>> joinColumnAnnotations = getJoinColumnAnnotations( property, inferredData );
final JoinColumn[] joinColumnAnnotations = getJoinColumnAnnotations( property, inferredData );
if ( joinColumnAnnotations != null ) {
return AnnotatedJoinColumns.buildJoinColumns(
joinColumnAnnotations,
@ -220,7 +215,7 @@ class ColumnsBuilder {
);
}
final List<AnnotationUsage<JoinColumnOrFormula>> joinColumnOrFormulaAnnotations = joinColumnOrFormulaAnnotations( property, inferredData );
final JoinColumnOrFormula[] joinColumnOrFormulaAnnotations = joinColumnOrFormulaAnnotations( property, inferredData );
if ( joinColumnOrFormulaAnnotations != null ) {
return AnnotatedJoinColumns.buildJoinColumnsOrFormulas(
joinColumnOrFormulaAnnotations,
@ -232,8 +227,8 @@ class ColumnsBuilder {
);
}
if ( property.hasAnnotationUsage( JoinFormula.class) ) {
final AnnotationUsage<JoinFormula> joinFormula = getOverridableAnnotation( property, JoinFormula.class, buildingContext );
if ( property.hasDirectAnnotationUsage( JoinFormula.class) ) {
final JoinFormula joinFormula = getOverridableAnnotation( property, JoinFormula.class, buildingContext );
return AnnotatedJoinColumns.buildJoinColumnsWithFormula(
joinFormula,
entityBinder.getSecondaryTables(),
@ -246,99 +241,50 @@ class ColumnsBuilder {
return null;
}
private List<AnnotationUsage<JoinColumnOrFormula>> joinColumnOrFormulaAnnotations(MemberDetails property, PropertyData inferredData) {
if ( property.hasAnnotationUsage( JoinColumnOrFormula.class ) ) {
return List.of( property.getAnnotationUsage( JoinColumnOrFormula.class ) );
}
if ( property.hasAnnotationUsage( JoinColumnsOrFormulas.class ) ) {
final AnnotationUsage<JoinColumnsOrFormulas> joinColumnsOrFormulas = property.getAnnotationUsage( JoinColumnsOrFormulas.class );
final List<AnnotationUsage<JoinColumnOrFormula>> joinColumnOrFormulaList = joinColumnsOrFormulas.getList( "value" );
if ( joinColumnOrFormulaList.isEmpty() ) {
throw new AnnotationException( "Property '" + getPath( propertyHolder, inferredData)
+ "' has an empty '@JoinColumnsOrFormulas' annotation" );
}
return joinColumnOrFormulaList;
private JoinColumnOrFormula[] joinColumnOrFormulaAnnotations(MemberDetails property, PropertyData inferredData) {
final SourceModelBuildingContext sourceModelContext = buildingContext.getMetadataCollector().getSourceModelBuildingContext();
final JoinColumnOrFormula[] annotations = property.getRepeatedAnnotationUsages(
HibernateAnnotations.JOIN_COLUMN_OR_FORMULA,
sourceModelContext
);
if ( CollectionHelper.isNotEmpty( annotations ) ) {
return annotations;
}
return null;
}
private List<AnnotationUsage<JoinColumn>> getJoinColumnAnnotations(MemberDetails property, PropertyData inferredData) {
if ( property.hasAnnotationUsage( JoinColumn.class ) ) {
return List.of( property.getAnnotationUsage( JoinColumn.class ) );
private JoinColumn[] getJoinColumnAnnotations(MemberDetails property, PropertyData inferredData) {
final SourceModelBuildingContext sourceModelContext = buildingContext.getMetadataCollector().getSourceModelBuildingContext();
final JoinColumn[] joinColumns = property.getRepeatedAnnotationUsages(
JpaAnnotations.JOIN_COLUMN,
sourceModelContext
);
if ( CollectionHelper.isNotEmpty( joinColumns ) ) {
return joinColumns;
}
if ( property.hasAnnotationUsage( JoinColumns.class ) ) {
final AnnotationUsage<JoinColumns> joinColumns = property.getAnnotationUsage( JoinColumns.class );
final List<AnnotationUsage<JoinColumn>> joinColumnsList = joinColumns.getList( "value" );
if ( joinColumnsList.isEmpty() ) {
throw new AnnotationException( "Property '" + getPath( propertyHolder, inferredData)
+ "' has an empty '@JoinColumns' annotation" );
}
return joinColumnsList;
}
if ( property.hasAnnotationUsage( MapsId.class ) ) {
if ( property.hasDirectAnnotationUsage( MapsId.class ) ) {
// inelegant solution to HHH-16463, let the PrimaryKeyJoinColumn
// masquerade as a regular JoinColumn (when a @OneToOne maps to
// the primary key of the child table, it's more elegant and more
// spec-compliant to map the association with @PrimaryKeyJoinColumn)
//
// todo : another option better leveraging hibernate-models would be to simply use an untyped AnnotationUsage
if ( property.hasAnnotationUsage( PrimaryKeyJoinColumns.class ) ) {
final List<AnnotationUsage<JoinColumn>> adapters = new ArrayList<>();
property.forEachAnnotationUsage( PrimaryKeyJoinColumn.class, (usage) -> {
adapters.add( makePrimaryKeyJoinColumnAdapter( usage, property ) );
} );
final PrimaryKeyJoinColumn[] primaryKeyJoinColumns = property.getRepeatedAnnotationUsages(
JpaAnnotations.PRIMARY_KEY_JOIN_COLUMN,
sourceModelContext
);
if ( CollectionHelper.isNotEmpty( primaryKeyJoinColumns ) ) {
final JoinColumn[] adapters = new JoinColumn[primaryKeyJoinColumns.length];
for ( int i = 0; i < primaryKeyJoinColumns.length; i++ ) {
final PrimaryKeyJoinColumn primaryKeyJoinColumn = primaryKeyJoinColumns[i];
adapters[i] = JoinColumnJpaAnnotation.toJoinColumn( primaryKeyJoinColumn, sourceModelContext );
}
return adapters;
}
else {
final AnnotationUsage<PrimaryKeyJoinColumn> pkJoinColumnAnn = property.getAnnotationUsage( PrimaryKeyJoinColumn.class );
if ( pkJoinColumnAnn != null ) {
return List.of( makePrimaryKeyJoinColumnAdapter( pkJoinColumnAnn, property ) );
}
else {
return null;
}
}
}
else {
return null;
}
}
private AnnotationUsage<JoinColumn> makePrimaryKeyJoinColumnAdapter(
AnnotationUsage<PrimaryKeyJoinColumn> pkJoinColumnAnn,
MemberDetails property) {
final SourceModelBuildingContext hibernateModelsContext = buildingContext.getMetadataCollector().getSourceModelBuildingContext();
final MutableAnnotationUsage<JoinColumn> usage = JpaAnnotations.JOIN_COLUMN.createUsage( hibernateModelsContext );
applyAttributeIfSpecified(
"name",
pkJoinColumnAnn.getAttributeValue( "name" ),
usage
);
applyAttributeIfSpecified(
"referencedColumnName",
pkJoinColumnAnn.getAttributeValue( "referencedColumnName" ),
usage
);
applyAttributeIfSpecified(
"columnDefinition",
pkJoinColumnAnn.getAttributeValue( "columnDefinition" ),
usage
);
applyAttributeIfSpecified(
"options",
pkJoinColumnAnn.getAttributeValue( "options" ),
usage
);
applyAttributeIfSpecified(
"foreignKey",
pkJoinColumnAnn.getAttributeValue( "foreignKey" ),
usage
);
return usage;
return null;
}
/**

View File

@ -8,7 +8,6 @@ package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.AnnotationException;
@ -21,7 +20,6 @@ import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails;
@ -111,7 +109,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
return false;
}
return memberDetails.hasAnnotationUsage( annotationType );
return memberDetails.hasDirectAnnotationUsage( annotationType );
}
private boolean hasAnnotation(
@ -149,7 +147,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
processAttributeConversions( embeddableTypeDetails, infoMap );
// then we can overlay any conversions from the Embedded attribute
embeddedMemberDetails.forEachAnnotationUsage( Convert.class, (usage) -> {
embeddedMemberDetails.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
final AttributeConversionInfo info = new AttributeConversionInfo( usage, embeddedMemberDetails );
if ( isEmpty( info.getAttributeName() ) ) {
throw new IllegalStateException( "Convert placed on Embedded attribute must define (sub)attributeName" );
@ -162,7 +160,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
private void processAttributeConversions(TypeDetails embeddableTypeDetails, Map<String, AttributeConversionInfo> infoMap) {
final ClassDetails embeddableClassDetails = embeddableTypeDetails.determineRawClass();
embeddableClassDetails.forEachAnnotationUsage( Convert.class, (usage) -> {
embeddableClassDetails.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
final AttributeConversionInfo info = new AttributeConversionInfo( usage, embeddableClassDetails );
if ( isEmpty( info.getAttributeName() ) ) {
throw new IllegalStateException( "@Convert placed on @Embeddable must define attributeName" );
@ -205,7 +203,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
return;
}
propertyMemberDetails.forEachAnnotationUsage( Convert.class, (usage) -> {
propertyMemberDetails.forEachAnnotationUsage( Convert.class, getSourceModelContext(), (usage) -> {
final AttributeConversionInfo info = new AttributeConversionInfo( usage, propertyMemberDetails );
attributeConversionInfoMap.put( attributeName, info );
} );
@ -263,12 +261,12 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
}
@Override
public Join addJoin(AnnotationUsage<JoinTable> joinTable, boolean noDelayInPkColumnCreation) {
public Join addJoin(JoinTable joinTable, boolean noDelayInPkColumnCreation) {
return parent.addJoin( joinTable, noDelayInPkColumnCreation );
}
@Override
public Join addJoin(AnnotationUsage<JoinTable> joinTable, Table table, boolean noDelayInPkColumnCreation) {
public Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation) {
return parent.addJoin( joinTable, table, noDelayInPkColumnCreation );
}
@ -340,9 +338,9 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
}
@Override
public List<AnnotationUsage<Column>> getOverriddenColumn(String propertyName) {
public Column[] getOverriddenColumn(String propertyName) {
//FIXME this is yukky
List<AnnotationUsage<Column>> result = super.getOverriddenColumn( propertyName );
Column[] result = super.getOverriddenColumn( propertyName );
if ( result == null ) {
final String userPropertyName = extractUserPropertyName( "id", propertyName );
if ( userPropertyName != null ) {

View File

@ -8,18 +8,18 @@ package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.annotations.DialectOverride;
import org.hibernate.boot.models.annotations.spi.DialectOverrider;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
/**
* @author Sanne Grinovero
@ -75,46 +75,34 @@ public class DialectOverridesAnnotationHelper {
return (Class<O>) OVERRIDE_MAP.get( annotationType );
}
public static <T extends Annotation> AnnotationUsage<T> getOverridableAnnotation(
public static <T extends Annotation> T getOverridableAnnotation(
AnnotationTarget element,
Class<T> annotationType,
MetadataBuildingContext context) {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final Class<? extends Annotation> overrideAnnotation = OVERRIDE_MAP.get( annotationType );
if ( overrideAnnotation != null ) {
// the requested annotation does have a DialectOverride variant - look for matching one of those...
final Dialect dialect = context.getMetadataCollector().getDatabase().getDialect();
final DatabaseVersion version = dialect.getVersion();
final List<? extends AnnotationUsage<? extends Annotation>> overrides = element.getRepeatedAnnotationUsages( overrideAnnotation );
for ( AnnotationUsage<? extends Annotation> override : overrides ) {
if ( overrideMatchesDialect( override, dialect ) ) {
// we found an override match...
// the override's `override` attribute is the thing to return
return override.getNestedUsage( "override" );
final Annotation[] overrides = element.getRepeatedAnnotationUsages( overrideAnnotation, sourceModelContext );
if ( CollectionHelper.isNotEmpty( overrides ) ) {
for ( int i = 0; i < overrides.length; i++ ) {
//noinspection unchecked
final DialectOverrider<T> override = (DialectOverrider<T>) overrides[i];
if ( override.matches( dialect ) ) {
return override.override();
}
}
}
}
// no override was found. return the base annotation (if one)
return element.getSingleAnnotationUsage( annotationType );
return element.getAnnotationUsage( annotationType, sourceModelContext );
}
public static boolean overrideMatchesDialect(AnnotationUsage<? extends Annotation> override, Dialect dialect) {
final ClassDetails overrideDialect = override.getClassDetails( "dialect" );
final Class<? extends Dialect> overrideDialectJavaType = overrideDialect.toJavaClass();
if ( !overrideDialectJavaType.isAssignableFrom( dialect.getClass() ) ) {
return false;
}
final AnnotationUsage<DialectOverride.Version> beforeAnn = override.getNestedUsage( "before" );
final AnnotationUsage<DialectOverride.Version> sameOrAfterAnn = override.getNestedUsage( "sameOrAfter" );
final DatabaseVersion version = dialect.getVersion();
if ( version.isBefore( beforeAnn.getInteger( "major" ), beforeAnn.getInteger( "minor" ) )
&& version.isSameOrAfter( sameOrAfterAnn.getInteger( "major" ), sameOrAfterAnn.getInteger( "minor" ) ) ) {
return true;
}
return false;
public static boolean overrideMatchesDialect(DialectOverrider<?> override, Dialect dialect) {
return override.matches( dialect );
}
}

View File

@ -24,6 +24,7 @@ import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
@ -31,11 +32,11 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.FieldDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.MethodDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.property.access.internal.PropertyAccessStrategyCompositeUserTypeImpl;
import org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl;
@ -160,18 +161,19 @@ public class EmbeddableBinder {
}
static boolean isEmbedded(MemberDetails property, ClassDetails returnedClass) {
return property.hasAnnotationUsage( Embedded.class )
|| property.hasAnnotationUsage( EmbeddedId.class )
|| returnedClass.hasAnnotationUsage( Embeddable.class ) && !property.hasAnnotationUsage( Convert.class );
return property.hasDirectAnnotationUsage( Embedded.class )
|| property.hasDirectAnnotationUsage( EmbeddedId.class )
|| returnedClass.hasDirectAnnotationUsage( Embeddable.class ) && !property.hasDirectAnnotationUsage( Convert.class );
}
static boolean isEmbedded(MemberDetails property, TypeDetails returnedClass) {
if ( property.hasAnnotationUsage( Embedded.class ) || property.hasAnnotationUsage( EmbeddedId.class ) ) {
if ( property.hasDirectAnnotationUsage( Embedded.class ) || property.hasDirectAnnotationUsage( EmbeddedId.class ) ) {
return true;
}
final ClassDetails returnClassDetails = returnedClass.determineRawClass();
return returnClassDetails.hasAnnotationUsage( Embeddable.class ) && !property.hasAnnotationUsage( Convert.class );
return returnClassDetails.hasDirectAnnotationUsage( Embeddable.class )
&& !property.hasDirectAnnotationUsage( Convert.class );
}
public static Component bindEmbeddable(
@ -234,14 +236,22 @@ public class EmbeddableBinder {
}
private static void callTypeBinders(Component component, MetadataBuildingContext context, TypeDetails annotatedClass ) {
final List<AnnotationUsage<?>> metaAnnotatedAnnotations = annotatedClass.determineRawClass().getMetaAnnotated( TypeBinderType.class );
for ( AnnotationUsage<?> metaAnnotated : metaAnnotatedAnnotations ) {
final AnnotationUsage<TypeBinderType> binderType = metaAnnotated.getAnnotationDescriptor().getAnnotationUsage( TypeBinderType.class );
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final List<? extends Annotation> metaAnnotatedAnnotations = annotatedClass.determineRawClass().getMetaAnnotated( TypeBinderType.class, sourceModelContext );
if ( CollectionHelper.isEmpty( metaAnnotatedAnnotations ) ) {
return;
}
for ( Annotation metaAnnotated : metaAnnotatedAnnotations ) {
final TypeBinderType binderType = metaAnnotated.annotationType().getAnnotation( TypeBinderType.class );
try {
final ClassDetails binderImpl = binderType.getClassDetails( "binder" );
final Class<? extends TypeBinder<Annotation>> binderJavaType = binderImpl.toJavaClass();
final TypeBinder<Annotation> binder = binderJavaType.getDeclaredConstructor().newInstance();
binder.bind( metaAnnotated.toAnnotation(), context, component );
//noinspection rawtypes
final Class<? extends TypeBinder> binderImpl = binderType.binder();
//noinspection rawtypes
final TypeBinder binder = binderImpl.getDeclaredConstructor().newInstance();
//noinspection unchecked
binder.bind( metaAnnotated, context, component );
}
catch ( Exception e ) {
throw new AnnotationException( "error processing @TypeBinderType annotation '" + metaAnnotated + "'", e );
@ -464,7 +474,7 @@ public class EmbeddableBinder {
);
final MemberDetails property = propertyAnnotatedElement.getAttributeMember();
if ( property.hasAnnotationUsage( GeneratedValue.class ) ) {
if ( property.hasDirectAnnotationUsage( GeneratedValue.class ) ) {
if ( isIdClass || subholder.isOrWithinEmbeddedId() ) {
processGeneratedId( context, component, property );
}
@ -529,8 +539,8 @@ public class EmbeddableBinder {
PropertyHolder holder,
InheritanceState inheritanceState,
MetadataBuildingContext context) {
final AnnotationUsage<DiscriminatorColumn> discriminatorColumn = annotatedClass.getAnnotationUsage( DiscriminatorColumn.class );
final AnnotationUsage<DiscriminatorFormula> discriminatorFormula = getOverridableAnnotation(
final DiscriminatorColumn discriminatorColumn = annotatedClass.getDirectAnnotationUsage( DiscriminatorColumn.class );
final DiscriminatorFormula discriminatorFormula = getOverridableAnnotation(
annotatedClass,
DiscriminatorFormula.class,
context
@ -539,7 +549,7 @@ public class EmbeddableBinder {
if ( inheritanceState.hasSiblings() ) {
final String path = qualify( holder.getPath(), EntityDiscriminatorMapping.DISCRIMINATOR_ROLE_NAME );
final String columnPrefix;
final List<AnnotationUsage<Column>> overrides;
final Column[] overrides;
if ( holder.isWithinElementCollection() ) {
columnPrefix = unqualify( parentHolder.getPath() );
overrides = parentHolder.getOverriddenColumn( path );
@ -551,7 +561,7 @@ public class EmbeddableBinder {
return buildDiscriminatorColumn(
discriminatorColumn,
discriminatorFormula,
overrides == null ? null : overrides.get(0),
overrides == null ? null : overrides[0],
columnPrefix + "_" + DEFAULT_DISCRIMINATOR_COLUMN_NAME,
context
);
@ -687,8 +697,8 @@ public class EmbeddableBinder {
ClassDetails annotatedClass,
BasicType<?> discriminatorType,
Map<Object, String> discriminatorValues) {
final String explicitValue = annotatedClass.hasAnnotationUsage( DiscriminatorValue.class )
? annotatedClass.getAnnotationUsage( DiscriminatorValue.class ).getString( "value" )
final String explicitValue = annotatedClass.hasDirectAnnotationUsage( DiscriminatorValue.class )
? annotatedClass.getDirectAnnotationUsage( DiscriminatorValue.class ).value()
: null;
final String discriminatorValue;
if ( isEmpty( explicitValue ) ) {
@ -721,7 +731,7 @@ public class EmbeddableBinder {
return false;
}
return superClass.hasAnnotationUsage( MappedSuperclass.class )
return superClass.hasDirectAnnotationUsage( MappedSuperclass.class )
|| ( isIdClass
&& !superClass.getName().equals( Object.class.getName() )
&& !superClass.getName().equals( "java.lang.Record" ) );
@ -793,21 +803,21 @@ public class EmbeddableBinder {
}
private static boolean hasTriggeringAnnotation(MemberDetails property) {
return property.hasAnnotationUsage(Column.class)
|| property.hasAnnotationUsage(OneToMany.class)
|| property.hasAnnotationUsage(ManyToOne.class)
|| property.hasAnnotationUsage(Id.class)
|| property.hasAnnotationUsage(GeneratedValue.class)
|| property.hasAnnotationUsage(OneToOne.class)
|| property.hasAnnotationUsage(ManyToMany.class);
return property.hasDirectAnnotationUsage(Column.class)
|| property.hasDirectAnnotationUsage(OneToMany.class)
|| property.hasDirectAnnotationUsage(ManyToOne.class)
|| property.hasDirectAnnotationUsage(Id.class)
|| property.hasDirectAnnotationUsage(GeneratedValue.class)
|| property.hasDirectAnnotationUsage(OneToOne.class)
|| property.hasDirectAnnotationUsage(ManyToMany.class);
}
private static void processGeneratedId(MetadataBuildingContext context, Component component, MemberDetails property) {
final AnnotationUsage<GeneratedValue> generatedValue = property.getAnnotationUsage( GeneratedValue.class );
final GeneratedValue generatedValue = property.getDirectAnnotationUsage( GeneratedValue.class );
final String generatorType = generatedValue != null
? generatorType( generatedValue, property.getType().determineRawClass(), context )
: GeneratorBinder.ASSIGNED_GENERATOR_NAME;
final String generator = generatedValue != null ? generatedValue.getString( "generator" ) : "";
final String generator = generatedValue != null ? generatedValue.generator() : "";
if ( isGlobalGeneratorNameGlobal( context ) ) {
buildGenerators( property, context );
@ -926,21 +936,21 @@ public class EmbeddableBinder {
MemberDetails property,
ClassDetails returnedClass,
MetadataBuildingContext context) {
if ( property.hasAnnotationUsage( EmbeddedId.class ) ) {
if ( property.hasDirectAnnotationUsage( EmbeddedId.class ) ) {
// we don't allow custom instantiators for composite ids
return null;
}
final AnnotationUsage<org.hibernate.annotations.EmbeddableInstantiator> propertyAnnotation =
property.getAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
final org.hibernate.annotations.EmbeddableInstantiator propertyAnnotation =
property.getDirectAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
if ( propertyAnnotation != null ) {
return propertyAnnotation.getClassDetails( "value" ).toJavaClass();
return propertyAnnotation.value();
}
final AnnotationUsage<org.hibernate.annotations.EmbeddableInstantiator> classAnnotation =
returnedClass.getAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
final org.hibernate.annotations.EmbeddableInstantiator classAnnotation =
returnedClass.getDirectAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
if ( classAnnotation != null ) {
return classAnnotation.getClassDetails( "value" ).toJavaClass();
return classAnnotation.value();
}
if ( returnedClass.getClassName() != null ) {

View File

@ -6,28 +6,26 @@
*/
package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.annotations.FetchProfile.FetchOverride;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.FetchProfile;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import java.util.Map;
/**
* @author Hardy Ferentschik
*/
public class FetchOverrideSecondPass implements SecondPass {
private final String fetchProfileName;
private final AnnotationUsage<FetchOverride> fetch;
private final FetchOverride fetch;
private final MetadataBuildingContext buildingContext;
public FetchOverrideSecondPass(
String fetchProfileName,
AnnotationUsage<FetchOverride> fetch,
FetchOverride fetch,
MetadataBuildingContext buildingContext) {
this.fetchProfileName = fetchProfileName;
this.fetch = fetch;
@ -36,8 +34,8 @@ public class FetchOverrideSecondPass implements SecondPass {
@Override
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
final ClassDetails entityClassDetails = fetch.getClassDetails( "entity" );
final String attributeName = fetch.getString( "association" );
final Class<?> entityClassDetails = fetch.entity();
final String attributeName = fetch.association();
// throws MappingException in case the property does not exist
buildingContext.getMetadataCollector()
@ -49,8 +47,8 @@ public class FetchOverrideSecondPass implements SecondPass {
profile.addFetch( new FetchProfile.Fetch(
entityClassDetails.getName(),
attributeName,
fetch.getEnum( "mode" ),
fetch.getEnum( "fetch" )
fetch.mode(),
fetch.fetch()
) );
}
}

View File

@ -15,7 +15,6 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.FetchProfile;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.models.spi.AnnotationUsage;
import static org.hibernate.internal.util.StringHelper.qualify;
import static org.hibernate.mapping.MetadataSource.ANNOTATIONS;
@ -24,13 +23,13 @@ import static org.hibernate.mapping.MetadataSource.ANNOTATIONS;
* @author Gavin King
*/
public class FetchSecondPass implements SecondPass {
private final AnnotationUsage<FetchProfileOverride> fetch;
private final FetchProfileOverride fetch;
private final PropertyHolder propertyHolder;
private final String propertyName;
private final MetadataBuildingContext buildingContext;
public FetchSecondPass(
AnnotationUsage<FetchProfileOverride> fetch,
FetchProfileOverride fetch,
PropertyHolder propertyHolder,
String propertyName,
MetadataBuildingContext buildingContext) {
@ -42,7 +41,7 @@ public class FetchSecondPass implements SecondPass {
@Override
public void doSecondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
final String profileName = fetch.getString( "profile" );
final String profileName = fetch.profile();
final FetchProfile profile = buildingContext.getMetadataCollector().getFetchProfile( profileName );
if ( profile == null ) {
throw new AnnotationException(
@ -55,8 +54,8 @@ public class FetchSecondPass implements SecondPass {
profile.addFetch( new FetchProfile.Fetch(
propertyHolder.getEntityName(),
propertyName,
fetch.getEnum( "mode" ),
fetch.getEnum( "fetch" )
fetch.mode(),
fetch.fetch()
) );
}
// otherwise, it's a fetch profile defined in XML, and it overrides

View File

@ -7,7 +7,6 @@
package org.hibernate.boot.model.internal;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Supplier;
@ -20,10 +19,10 @@ import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.type.descriptor.java.JavaType;
@ -45,31 +44,32 @@ public class FilterDefBinder {
private static final CoreMessageLogger LOG = messageLogger( FilterDefBinder.class );
public static void bindFilterDefs(AnnotationTarget annotatedElement, MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( FilterDef.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( FilterDef.class, sourceModelContext, (usage) -> {
bindFilterDef( usage, context );
} );
}
public static void bindFilterDef(AnnotationUsage<FilterDef> filterDef, MetadataBuildingContext context) {
final String name = filterDef.getString( "name" );
public static void bindFilterDef(FilterDef filterDef, MetadataBuildingContext context) {
final String name = filterDef.name();
if ( context.getMetadataCollector().getFilterDefinition( name ) != null ) {
throw new AnnotationException( "Multiple '@FilterDef' annotations define a filter named '" + name + "'" );
}
final Map<String, JdbcMapping> paramJdbcMappings;
final Map<String, ManagedBean<? extends Supplier<?>>> parameterResolvers;
final List<AnnotationUsage<ParamDef>> explicitParameters = filterDef.getList( "parameters" );
if ( explicitParameters.isEmpty() ) {
final ParamDef[] explicitParameters = filterDef.parameters();
if ( CollectionHelper.isEmpty( explicitParameters ) ) {
paramJdbcMappings = emptyMap();
parameterResolvers = emptyMap();
}
else {
paramJdbcMappings = new HashMap<>();
parameterResolvers = new HashMap<>();
for ( AnnotationUsage<ParamDef> explicitParameter : explicitParameters ) {
final String parameterName = explicitParameter.getString( "name" );
final ClassDetails typeClassDetails = explicitParameter.getClassDetails( "type" );
final JdbcMapping jdbcMapping = resolveFilterParamType( typeClassDetails.toJavaClass(), context );
for ( ParamDef explicitParameter : explicitParameters ) {
final String parameterName = explicitParameter.name();
final Class<?> typeClassDetails = explicitParameter.type();
final JdbcMapping jdbcMapping = resolveFilterParamType( typeClassDetails, context );
if ( jdbcMapping == null ) {
throw new MappingException(
String.format(
@ -82,17 +82,17 @@ public class FilterDefBinder {
}
paramJdbcMappings.put( parameterName, jdbcMapping );
final ClassDetails resolverClassDetails = explicitParameter.getClassDetails( "resolver" );
if ( !resolverClassDetails.getName().equals( Supplier.class.getName() ) ) {
parameterResolvers.put( explicitParameter.getString( "name" ), resolveParamResolver( resolverClassDetails, context ) );
final Class<? extends Supplier> resolverClass = explicitParameter.resolver();
if ( !Supplier.class.equals( resolverClass ) ) {
parameterResolvers.put( explicitParameter.name(), resolveParamResolver( resolverClass, context ) );
}
}
}
final FilterDefinition filterDefinition = new FilterDefinition(
name,
filterDef.getString( "defaultCondition" ),
filterDef.getBoolean( "autoEnabled" ),
filterDef.defaultCondition(),
filterDef.autoEnabled(),
filterDef.applyToLoadByKey(),
paramJdbcMappings,
parameterResolvers
@ -103,13 +103,12 @@ public class FilterDefBinder {
}
@SuppressWarnings({"rawtypes", "unchecked"})
private static ManagedBean<? extends Supplier<?>> resolveParamResolver(ClassDetails resolverClassDetails, MetadataBuildingContext context) {
final Class<? extends Supplier> clazz = resolverClassDetails.toJavaClass();
assert clazz != Supplier.class;
private static ManagedBean<? extends Supplier<?>> resolveParamResolver(Class<? extends Supplier> resolverClass, MetadataBuildingContext context) {
assert resolverClass != Supplier.class;
final BootstrapContext bootstrapContext = context.getBootstrapContext();
return (ManagedBean<? extends Supplier<?>>) bootstrapContext.getServiceRegistry()
.requireService(ManagedBeanRegistry.class)
.getBean(clazz, bootstrapContext.getCustomTypeProducer());
.getBean(resolverClass, bootstrapContext.getCustomTypeProducer());
}
@SuppressWarnings("unchecked")

View File

@ -32,6 +32,7 @@ import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.generator.AnnotationBasedGenerator;
import org.hibernate.generator.Assigned;
import org.hibernate.generator.BeforeExecutionGenerator;
import org.hibernate.generator.CustomIdGeneratorCreationContext;
import org.hibernate.generator.Generator;
import org.hibernate.generator.GeneratorCreationContext;
import org.hibernate.generator.OnExecutionGenerator;
@ -49,7 +50,6 @@ import org.hibernate.id.UUIDHexGenerator;
import org.hibernate.id.enhanced.LegacyNamingStrategy;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.SingleNamingStrategy;
import org.hibernate.generator.CustomIdGeneratorCreationContext;
import org.hibernate.internal.CoreLogging;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.GeneratorCreator;
@ -58,16 +58,15 @@ import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.Type;
import org.jboss.logging.Logger;
import jakarta.persistence.GeneratedValue;
@ -77,6 +76,7 @@ import jakarta.persistence.TableGenerator;
import jakarta.persistence.Version;
import static java.util.Collections.emptyMap;
import static org.hibernate.boot.internal.GenerationStrategyInterpreter.STRATEGY_INTERPRETER;
import static org.hibernate.boot.model.internal.AnnotationHelper.extractParameterMap;
import static org.hibernate.boot.model.internal.BinderHelper.isCompositeId;
import static org.hibernate.boot.model.internal.BinderHelper.isGlobalGeneratorNameGlobal;
@ -338,7 +338,7 @@ public class GeneratorBinder {
LOG.debugf( "Could not resolve explicit IdentifierGeneratorDefinition - using implicit interpretation (%s)", name );
final AnnotationUsage<GeneratedValue> generatedValue = idAttributeMember.getAnnotationUsage( GeneratedValue.class );
final GeneratedValue generatedValue = idAttributeMember.getDirectAnnotationUsage( GeneratedValue.class );
if ( generatedValue == null ) {
// this should really never happen, but it's easy to protect against it...
return new IdentifierGeneratorDefinition(ASSIGNED_GENERATOR_NAME, ASSIGNED_GENERATOR_NAME);
@ -347,38 +347,38 @@ public class GeneratorBinder {
return IdentifierGeneratorDefinition.createImplicit(
name,
idAttributeMember.getType().determineRawClass().toJavaClass(),
generatedValue.getString( "generator" ),
generatedValue.generator(),
interpretGenerationType( generatedValue )
);
}
private static GenerationType interpretGenerationType(AnnotationUsage<GeneratedValue> generatedValueAnn) {
private static GenerationType interpretGenerationType(GeneratedValue generatedValueAnn) {
// todo (jpa32) : when can this ever be null?
final GenerationType strategy = generatedValueAnn.getEnum( "strategy" );
final GenerationType strategy = generatedValueAnn.strategy();
return strategy == null ? GenerationType.AUTO : strategy;
}
public static Map<String, IdentifierGeneratorDefinition> buildGenerators(
AnnotationTarget annotatedElement,
MetadataBuildingContext context) {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final InFlightMetadataCollector metadataCollector = context.getMetadataCollector();
final Map<String, IdentifierGeneratorDefinition> generators = new HashMap<>();
annotatedElement.forEachAnnotationUsage( TableGenerator.class, usage -> {
IdentifierGeneratorDefinition idGenerator = buildTableIdGenerator( usage );
annotatedElement.forEachAnnotationUsage( TableGenerator.class, sourceModelContext, (usage) -> {
IdentifierGeneratorDefinition idGenerator = buildIdGenerator( usage, context );
generators.put( idGenerator.getName(), idGenerator );
metadataCollector.addIdentifierGenerator( idGenerator );
} );
annotatedElement.forEachAnnotationUsage( SequenceGenerator.class, usage -> {
IdentifierGeneratorDefinition idGenerator = buildSequenceIdGenerator( usage );
annotatedElement.forEachAnnotationUsage( SequenceGenerator.class, sourceModelContext, (usage) -> {
IdentifierGeneratorDefinition idGenerator = buildIdGenerator( usage, context );
generators.put( idGenerator.getName(), idGenerator );
metadataCollector.addIdentifierGenerator( idGenerator );
} );
annotatedElement.forEachAnnotationUsage( GenericGenerator.class, usage -> {
final IdentifierGeneratorDefinition idGenerator = buildIdGenerator( usage );
annotatedElement.forEachAnnotationUsage( GenericGenerator.class, sourceModelContext, (usage) -> {
final IdentifierGeneratorDefinition idGenerator = buildIdGenerator( usage, context );
generators.put( idGenerator.getName(), idGenerator );
metadataCollector.addIdentifierGenerator( idGenerator );
} );
@ -390,7 +390,7 @@ public class GeneratorBinder {
MetadataBuildingContext context,
ClassDetails entityXClass,
boolean isComponent,
AnnotationUsage<GeneratedValue> generatedValue) {
GeneratedValue generatedValue) {
if ( isComponent ) {
//a component must not have any generator
return ASSIGNED_GENERATOR_NAME;
@ -401,11 +401,11 @@ public class GeneratorBinder {
}
static String generatorType(
AnnotationUsage<GeneratedValue> generatedValue,
GeneratedValue generatedValue,
final ClassDetails javaClass,
MetadataBuildingContext context) {
return GenerationStrategyInterpreter.STRATEGY_INTERPRETER.determineGeneratorName(
generatedValue.getEnum( "strategy" ),
return STRATEGY_INTERPRETER.determineGeneratorName(
generatedValue.strategy(),
new GenerationStrategyInterpreter.GeneratorNameDeterminationContext() {
Class<?> javaType = null;
@Override
@ -417,54 +417,61 @@ public class GeneratorBinder {
}
@Override
public String getGeneratedValueGeneratorName() {
return generatedValue.getString( "generator" );
return generatedValue.generator();
}
}
);
}
static IdentifierGeneratorDefinition buildIdGenerator(AnnotationUsage<GenericGenerator> generatorAnnotation) {
static IdentifierGeneratorDefinition buildIdGenerator(
Annotation generatorAnnotation,
MetadataBuildingContext context) {
if ( generatorAnnotation == null ) {
return null;
}
final IdentifierGeneratorDefinition.Builder definitionBuilder = new IdentifierGeneratorDefinition.Builder();
definitionBuilder.setName( generatorAnnotation.getString( "name" ) );
final Class<? extends Generator> generatorClass =
generatorAnnotation.getClassDetails( "type" ).toJavaClass();
final String strategy = generatorClass.equals(Generator.class)
? generatorAnnotation.getString( "strategy" )
: generatorClass.getName();
definitionBuilder.setStrategy( strategy );
definitionBuilder.addParams( extractParameterMap( generatorAnnotation.getList( "parameters" ) ) );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add generic generator with name: {0}", definitionBuilder.getName() );
}
return definitionBuilder.build();
}
static IdentifierGeneratorDefinition buildTableIdGenerator(AnnotationUsage<TableGenerator> generatorAnnotation) {
if ( generatorAnnotation == null ) {
return null;
}
final IdentifierGeneratorDefinition.Builder definitionBuilder = new IdentifierGeneratorDefinition.Builder();
GenerationStrategyInterpreter.STRATEGY_INTERPRETER
.interpretTableGenerator( generatorAnnotation, definitionBuilder );
if ( generatorAnnotation instanceof TableGenerator tableGenerator ) {
STRATEGY_INTERPRETER.interpretTableGenerator(
tableGenerator,
definitionBuilder
);
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add table generator with name: {0}", definitionBuilder.getName() );
}
}
else if ( generatorAnnotation instanceof SequenceGenerator sequenceGenerator ) {
STRATEGY_INTERPRETER.interpretSequenceGenerator(
sequenceGenerator,
definitionBuilder
);
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add sequence generator with name: {0}", definitionBuilder.getName() );
}
}
else if ( generatorAnnotation instanceof GenericGenerator genericGenerator ) {
definitionBuilder.setName( genericGenerator.name() );
final Class<? extends Generator> generatorClass = genericGenerator.type();
final String strategy = generatorClass.equals( Generator.class )
? genericGenerator.strategy()
: generatorClass.getName();
definitionBuilder.setStrategy( strategy );
definitionBuilder.addParams( extractParameterMap( genericGenerator.parameters() ) );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add generic generator with name: {0}", definitionBuilder.getName() );
}
}
return definitionBuilder.build();
}
static IdentifierGeneratorDefinition buildSequenceIdGenerator(AnnotationUsage<SequenceGenerator> generatorAnnotation) {
static IdentifierGeneratorDefinition buildSequenceIdGenerator(SequenceGenerator generatorAnnotation) {
if ( generatorAnnotation == null ) {
return null;
}
final IdentifierGeneratorDefinition.Builder definitionBuilder = new IdentifierGeneratorDefinition.Builder();
GenerationStrategyInterpreter.STRATEGY_INTERPRETER
.interpretSequenceGenerator( generatorAnnotation, definitionBuilder );
STRATEGY_INTERPRETER.interpretSequenceGenerator( generatorAnnotation, definitionBuilder );
if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add sequence generator with name: {0}", definitionBuilder.getName() );
}
@ -501,9 +508,9 @@ public class GeneratorBinder {
*/
static GeneratorCreator generatorCreator(
MemberDetails memberDetails,
AnnotationUsage<?> annotation,
Annotation annotation,
BeanContainer beanContainer) {
final Class<? extends Annotation> annotationType = annotation.getAnnotationType();
final Class<? extends Annotation> annotationType = annotation.annotationType();
final ValueGenerationType generatorAnnotation = annotationType.getAnnotation( ValueGenerationType.class );
if ( generatorAnnotation == null ) {
return null;
@ -528,10 +535,10 @@ public class GeneratorBinder {
static IdentifierGeneratorCreator identifierGeneratorCreator(
MemberDetails idAttributeMember,
AnnotationUsage<? extends Annotation> annotation,
Annotation annotation,
SimpleValue identifierValue,
BeanContainer beanContainer) {
final Class<? extends Annotation> annotationType = annotation.getAnnotationType();
final Class<? extends Annotation> annotationType = annotation.annotationType();
final IdGeneratorType idGeneratorType = annotationType.getAnnotation( IdGeneratorType.class );
assert idGeneratorType != null;
final Class<? extends Generator> generatorClass = idGeneratorType.value();
@ -563,7 +570,7 @@ public class GeneratorBinder {
* @param generatorClass a class which implements {@code Generator}
*/
private static <C> Generator instantiateGenerator(
AnnotationUsage<? extends Annotation> annotation,
Annotation annotation,
BeanContainer beanContainer,
C creationContext,
Class<C> creationContextClass,
@ -602,7 +609,7 @@ public class GeneratorBinder {
* @param generatorClass a class which implements {@code Generator}
*/
private static <C> Generator instantiateGeneratorAsBean(
AnnotationUsage<? extends Annotation> annotation,
Annotation annotation,
BeanContainer beanContainer,
C creationContext,
Class<C> creationContextClass,
@ -691,7 +698,7 @@ public class GeneratorBinder {
* @param generatorClass a class which implements {@code Generator}
*/
private static <C, G extends Generator> G instantiateGenerator(
AnnotationUsage<?> annotation,
Annotation annotation,
MemberDetails memberDetails,
Class<? extends Annotation> annotationType,
C creationContext,
@ -700,12 +707,12 @@ public class GeneratorBinder {
try {
try {
return generatorClass.getConstructor( annotationType, Member.class, contextClass )
.newInstance( annotation.toAnnotation(), memberDetails.toJavaMember(), creationContext);
.newInstance( annotation, memberDetails.toJavaMember(), creationContext);
}
catch (NoSuchMethodException ignore) {
try {
return generatorClass.getConstructor( annotationType )
.newInstance( annotation.toAnnotation() );
.newInstance( annotation );
}
catch (NoSuchMethodException i) {
return instantiateGeneratorViaDefaultConstructor( generatorClass );
@ -751,7 +758,7 @@ public class GeneratorBinder {
}
private static <A extends Annotation> void callInitialize(
AnnotationUsage<A> annotation,
A annotation,
MemberDetails memberDetails,
GeneratorCreationContext creationContext,
Generator generator) {
@ -761,12 +768,12 @@ public class GeneratorBinder {
// check this explicitly; If required, this could be done e.g. using ClassMate
@SuppressWarnings("unchecked")
final AnnotationBasedGenerator<A> generation = (AnnotationBasedGenerator<A>) generator;
generation.initialize( annotation.toAnnotation(), memberDetails.toJavaMember(), creationContext );
generation.initialize( annotation, memberDetails.toJavaMember(), creationContext );
}
}
private static void checkVersionGenerationAlways(MemberDetails property, Generator generator) {
if ( property.hasAnnotationUsage(Version.class) ) {
if ( property.hasDirectAnnotationUsage( Version.class ) ) {
if ( !generator.generatesOnInsert() ) {
throw new AnnotationException("Property '" + property.getName()
+ "' is annotated '@Version' but has a 'Generator' which does not generate on inserts"
@ -821,9 +828,9 @@ public class GeneratorBinder {
MemberDetails idAttributeMember) {
//manage composite related metadata
//guess if its a component and find id data access (property, field etc)
final AnnotationUsage<GeneratedValue> generatedValue = idAttributeMember.getAnnotationUsage( GeneratedValue.class );
final GeneratedValue generatedValue = idAttributeMember.getDirectAnnotationUsage( GeneratedValue.class );
final String generatorType = generatorType( context, entityClass, isCompositeId( entityClass, idAttributeMember ), generatedValue );
final String generatorName = generatedValue == null ? "" : generatedValue.getString( "generator" );
final String generatorName = generatedValue == null ? "" : generatedValue.generator();
if ( isGlobalGeneratorNameGlobal( context ) ) {
buildGenerators( idAttributeMember, context );
context.getMetadataCollector()

View File

@ -7,7 +7,6 @@
package org.hibernate.boot.model.internal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
@ -22,10 +21,11 @@ import org.hibernate.mapping.IdentifierBag;
import org.hibernate.mapping.IdentifierCollection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.usertype.UserCollectionType;
import jakarta.persistence.Column;
import static org.hibernate.boot.model.internal.GeneratorBinder.makeIdGenerator;
/**
@ -51,7 +51,7 @@ public class IdBagBinder extends BagBinder {
protected boolean bindStarToManySecondPass(Map<String, PersistentClass> persistentClasses) {
boolean result = super.bindStarToManySecondPass( persistentClasses );
final AnnotationUsage<CollectionId> collectionIdAnn = property.getAnnotationUsage( CollectionId.class );
final CollectionId collectionIdAnn = property.getDirectAnnotationUsage( CollectionId.class );
if ( collectionIdAnn == null ) {
throw new MappingException( "idbag mapping missing '@CollectionId' annotation" );
}
@ -69,7 +69,7 @@ public class IdBagBinder extends BagBinder {
);
final AnnotatedColumns idColumns = AnnotatedColumn.buildColumnsFromAnnotations(
List.of( collectionIdAnn.getNestedUsage( "column" ) ),
new Column[]{collectionIdAnn.column()},
// null,
null,
Nullability.FORCED_NOT_NULL,
@ -101,7 +101,7 @@ public class IdBagBinder extends BagBinder {
final BasicValue id = valueBinder.make();
( (IdentifierCollection) collection ).setIdentifier( id );
final String namedGenerator = collectionIdAnn.getString( "generator" );
final String namedGenerator = collectionIdAnn.generator();
switch (namedGenerator) {
case "identity": {

View File

@ -6,7 +6,8 @@
*/
package org.hibernate.boot.model.internal;
import jakarta.persistence.JoinTable;
import java.util.Map;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
@ -17,9 +18,8 @@ import org.hibernate.mapping.Join;
import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import java.util.Map;
import jakarta.persistence.JoinTable;
import static org.hibernate.boot.model.internal.ToOneBinder.getReferenceEntityName;
import static org.hibernate.internal.util.StringHelper.isEmpty;
@ -38,7 +38,7 @@ public class ImplicitToOneJoinTableSecondPass implements SecondPass {
private final PropertyData inferredData;
private final MetadataBuildingContext context;
private final AnnotatedJoinColumns joinColumns;
private final AnnotationUsage<JoinTable> joinTable;
private final JoinTable joinTable;
private final NotFoundAction notFoundAction;
private final ManyToOne value;
@ -47,7 +47,7 @@ public class ImplicitToOneJoinTableSecondPass implements SecondPass {
PropertyData inferredData,
MetadataBuildingContext context,
AnnotatedJoinColumns joinColumns,
AnnotationUsage<JoinTable> joinTable,
JoinTable joinTable,
NotFoundAction notFoundAction,
ManyToOne value) {
this.propertyHolder = propertyHolder;
@ -89,24 +89,24 @@ public class ImplicitToOneJoinTableSecondPass implements SecondPass {
final TableBinder tableBinder = new TableBinder();
tableBinder.setBuildingContext( context );
final String schema = joinTable.getString( "schema" );
final String schema = joinTable.schema();
if ( StringHelper.isNotEmpty( schema ) ) {
tableBinder.setSchema( schema );
}
final String catalog = joinTable.getString( "catalog" );
final String catalog = joinTable.catalog();
if ( StringHelper.isNotEmpty( catalog ) ) {
tableBinder.setCatalog( catalog );
}
final String tableName = joinTable.getString( "name" );
final String tableName = joinTable.name();
if ( StringHelper.isNotEmpty( tableName ) ) {
tableBinder.setName( tableName );
}
tableBinder.setUniqueConstraints( joinTable.getList( "uniqueConstraints" ) );
tableBinder.setJpaIndex( joinTable.getList( "indexes" ) );
tableBinder.setOptions( joinTable.getString( "options" ) );
tableBinder.setUniqueConstraints( joinTable.uniqueConstraints() );
tableBinder.setJpaIndex( joinTable.indexes() );
tableBinder.setOptions( joinTable.options() );
return tableBinder;
}

View File

@ -20,14 +20,12 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Formula;
import org.hibernate.mapping.Index;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.UniqueConstraint;
@ -115,8 +113,8 @@ class IndexBinder {
return new Column( physicalName );
}
private Selectable[] selectables(Table table, String name, List<String> columnNames) {
final int size = columnNames.size();
private Selectable[] selectables(Table table, String name, String[] columnNames) {
final int size = columnNames.length;
if ( size == 0 ) {
throw new AnnotationException( "Index"
+ ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -124,7 +122,7 @@ class IndexBinder {
}
final Selectable[] columns = new Selectable[size];
for ( int index = 0; index < size; index++ ) {
final String columnName = columnNames.get( index );
final String columnName = columnNames[index];
if ( isEmpty( columnName ) ) {
throw new AnnotationException( "Index"
+ ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -135,8 +133,8 @@ class IndexBinder {
return columns;
}
private Column[] columns(Table table, String name, final List<String> columnNames) {
final int size = columnNames.size();
private Column[] columns(Table table, String name, final String[] columnNames) {
final int size = columnNames.length;
if ( size == 0 ) {
throw new AnnotationException( "Unique constraint"
+ ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -144,7 +142,7 @@ class IndexBinder {
}
final Column[] columns = new Column[size];
for ( int index = 0; index < size; index++ ) {
final String columnName = columnNames.get( index );
final String columnName = columnNames[index];
if ( isEmpty( columnName ) ) {
throw new AnnotationException( "Unique constraint"
+ ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -159,7 +157,7 @@ class IndexBinder {
Table table,
String originalKeyName,
boolean nameExplicit,
List<String> columnNames,
String[] columnNames,
String[] orderings,
boolean unique,
Selectable[] columns) {
@ -190,9 +188,9 @@ class IndexBinder {
}
}
void bindIndexes(Table table, List<AnnotationUsage<jakarta.persistence.Index>> indexes) {
for ( AnnotationUsage<jakarta.persistence.Index> index : indexes ) {
final StringTokenizer tokenizer = new StringTokenizer( index.getString( "columnList" ), "," );
void bindIndexes(Table table, jakarta.persistence.Index[] indexes) {
for ( jakarta.persistence.Index index : indexes ) {
final StringTokenizer tokenizer = new StringTokenizer( index.columnList(), "," );
final List<String> parsed = new ArrayList<>();
while ( tokenizer.hasMoreElements() ) {
final String trimmed = tokenizer.nextToken().trim();
@ -200,11 +198,11 @@ class IndexBinder {
parsed.add( trimmed ) ;
}
}
final List<String> columnExpressions = CollectionHelper.populatedArrayList( parsed.size(), null );
final String[] columnExpressions = new String[parsed.size()];
final String[] ordering = new String[parsed.size()];
initializeColumns( columnExpressions, ordering, parsed );
final String name = index.getString( "name" );
final boolean unique = index.getBoolean( "unique" );
final String name = index.name();
final boolean unique = index.unique();
createIndexOrUniqueKey(
table,
name,
@ -217,10 +215,10 @@ class IndexBinder {
}
}
void bindUniqueConstraints(Table table, List<AnnotationUsage<UniqueConstraint>> constraints) {
for ( AnnotationUsage<UniqueConstraint> constraint : constraints ) {
final String name = constraint.getString( "name" );
final List<String> columnNames = constraint.getList( "columnNames" );
void bindUniqueConstraints(Table table, UniqueConstraint[] constraints) {
for ( UniqueConstraint constraint : constraints ) {
final String name = constraint.name();
final String[] columnNames = constraint.columnNames();
createIndexOrUniqueKey(
table,
name,
@ -233,20 +231,20 @@ class IndexBinder {
}
}
private void initializeColumns(List<String> columns, String[] ordering, List<String> list) {
private void initializeColumns(String[] columns, String[] ordering, List<String> list) {
for ( int i = 0, size = list.size(); i < size; i++ ) {
final String description = list.get( i );
final String tmp = description.toLowerCase(Locale.ROOT);
if ( tmp.endsWith( " desc" ) ) {
columns.set( i, description.substring( 0, description.length() - 5 ) );
columns[i] = description.substring( 0, description.length() - 5 );
ordering[i] = "desc";
}
else if ( tmp.endsWith( " asc" ) ) {
columns.set( i, description.substring( 0, description.length() - 4 ) );
columns[i] = description.substring( 0, description.length() - 4 );
ordering[i] = "asc";
}
else {
columns.set( i, description );
columns[i] = description;
ordering[i] = null;
}
}
@ -255,10 +253,10 @@ class IndexBinder {
private class IndexOrUniqueKeyNameSource implements ImplicitIndexNameSource, ImplicitUniqueKeyNameSource {
private final MetadataBuildingContext buildingContext;
private final Table table;
private final List<String> columnNames;
private final String[] columnNames;
private final String originalKeyName;
public IndexOrUniqueKeyNameSource(MetadataBuildingContext buildingContext, Table table, List<String> columnNames, String originalKeyName) {
public IndexOrUniqueKeyNameSource(MetadataBuildingContext buildingContext, Table table, String[] columnNames, String originalKeyName) {
this.buildingContext = buildingContext;
this.table = table;
this.columnNames = columnNames;
@ -292,12 +290,12 @@ class IndexBinder {
}
}
private List<Identifier> toIdentifiers(List<String> names) {
private List<Identifier> toIdentifiers(String[] names) {
if ( names == null ) {
return emptyList();
}
final List<Identifier> columnNames = arrayList( names.size() );
final List<Identifier> columnNames = arrayList( names.length );
for ( String name : names ) {
columnNames.add( getDatabase().toIdentifier( name ) );
}

View File

@ -12,7 +12,6 @@ import org.hibernate.annotations.ListIndexBase;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.Join;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.OrderColumn;
@ -33,9 +32,9 @@ public class IndexColumn extends AnnotatedColumn {
}
public static IndexColumn fromAnnotations(
AnnotationUsage<OrderColumn> orderColumn,
AnnotationUsage<org.hibernate.annotations.IndexColumn> indexColumn,
AnnotationUsage<ListIndexBase> listIndexBase,
OrderColumn orderColumn,
org.hibernate.annotations.IndexColumn indexColumn,
ListIndexBase listIndexBase,
PropertyHolder propertyHolder,
PropertyData inferredData,
Map<String, Join> secondaryTables,
@ -46,7 +45,7 @@ public class IndexColumn extends AnnotatedColumn {
}
else if ( indexColumn != null ) {
column = buildColumnFromIndexColumn( indexColumn, propertyHolder, inferredData, context );
column.setBase( indexColumn.getInteger( "base" ) );
column.setBase( indexColumn.base() );
}
else {
column = new IndexColumn();
@ -59,7 +58,7 @@ public class IndexColumn extends AnnotatedColumn {
}
if ( listIndexBase != null ) {
column.setBase( listIndexBase.getInteger( "value" ) );
column.setBase( listIndexBase.value() );
}
return column;
@ -96,25 +95,25 @@ public class IndexColumn extends AnnotatedColumn {
* @return The index column
*/
public static IndexColumn buildColumnFromOrderColumn(
AnnotationUsage<OrderColumn> orderColumn,
OrderColumn orderColumn,
PropertyHolder propertyHolder,
PropertyData inferredData,
Map<String, Join> secondaryTables,
MetadataBuildingContext context) {
if ( orderColumn != null ) {
final String sqlType = nullIfEmpty( orderColumn.getString( "columnDefinition" ) );
final String explicitName = orderColumn.getString( "name" );
final String sqlType = nullIfEmpty( orderColumn.columnDefinition() );
final String explicitName = orderColumn.name();
final String name = explicitName.isEmpty()
? inferredData.getPropertyName() + "_ORDER"
: explicitName;
final IndexColumn column = new IndexColumn();
column.setLogicalColumnName( name );
column.setSqlType( sqlType );
column.setNullable( orderColumn.getBoolean( "nullable" ) );
column.setNullable( orderColumn.nullable() );
// column.setJoins( secondaryTables );
column.setInsertable( orderColumn.getBoolean( "insertable" ) );
column.setUpdatable( orderColumn.getBoolean( "updatable" ) );
column.setOptions( orderColumn.getString( "options" ) );
column.setInsertable( orderColumn.insertable() );
column.setUpdatable( orderColumn.updatable() );
column.setOptions( orderColumn.options() );
// column.setContext( context );
// column.setPropertyHolder( propertyHolder );
createParent( propertyHolder, secondaryTables, column, context );
@ -142,22 +141,22 @@ public class IndexColumn extends AnnotatedColumn {
* @return The index column
*/
public static IndexColumn buildColumnFromIndexColumn(
AnnotationUsage<org.hibernate.annotations.IndexColumn> indexColumn,
org.hibernate.annotations.IndexColumn indexColumn,
PropertyHolder propertyHolder,
PropertyData inferredData,
MetadataBuildingContext context) {
if ( indexColumn != null ) {
final String explicitName = indexColumn.getString( "name" );
final String explicitName = indexColumn.name();
final String name = explicitName.isEmpty()
? inferredData.getPropertyName()
: explicitName;
final String sqlType = nullIfEmpty( indexColumn.getString( "columnDefinition" ) );
final String sqlType = nullIfEmpty( indexColumn.columnDefinition() );
//TODO move it to a getter based system and remove the constructor
final IndexColumn column = new IndexColumn();
column.setLogicalColumnName( name );
column.setSqlType( sqlType );
column.setNullable( indexColumn.getBoolean( "nullable" ) );
column.setBase( indexColumn.getInteger( "base" ) );
column.setNullable( indexColumn.nullable() );
column.setBase( indexColumn.base() );
// column.setContext( context );
// column.setPropertyHolder( propertyHolder );
createParent( propertyHolder, null, column, context );

View File

@ -72,14 +72,14 @@ public class InheritanceState {
}
private void extractInheritanceType(ClassDetails classDetails) {
final AnnotationUsage<Inheritance> inheritanceAnn = classDetails.getAnnotationUsage( Inheritance.class );
final AnnotationUsage<MappedSuperclass> mappedSuperAnn = classDetails.getAnnotationUsage( MappedSuperclass.class );
final Inheritance inheritanceAnn = classDetails.getDirectAnnotationUsage( Inheritance.class );
final MappedSuperclass mappedSuperAnn = classDetails.getDirectAnnotationUsage( MappedSuperclass.class );
if ( mappedSuperAnn != null ) {
setEmbeddableSuperclass( true );
setType( inheritanceAnn == null ? null : inheritanceAnn.getEnum( "strategy", InheritanceType.class ) );
setType( inheritanceAnn == null ? null : inheritanceAnn.strategy() );
}
else {
setType( inheritanceAnn == null ? SINGLE_TABLE : inheritanceAnn.getEnum( "strategy", InheritanceType.class ) );
setType( inheritanceAnn == null ? SINGLE_TABLE : inheritanceAnn.strategy() );
}
}
@ -182,7 +182,7 @@ public class InheritanceState {
if ( !evenIfSubclass && hasParents() ) {
return null;
}
else if ( classDetails.hasAnnotationUsage( IdClass.class ) ) {
else if ( classDetails.hasDirectAnnotationUsage( IdClass.class ) ) {
return classDetails;
}
else {
@ -205,7 +205,7 @@ public class InheritanceState {
else {
final ElementsToProcess process = getElementsToProcess();
for ( PropertyData property : process.getElements() ) {
if ( property.getAttributeMember().hasAnnotationUsage( EmbeddedId.class ) ) {
if ( property.getAttributeMember().hasDirectAnnotationUsage( EmbeddedId.class ) ) {
hasIdClassOrEmbeddedId = true;
break;
}
@ -259,9 +259,9 @@ public class InheritanceState {
private AccessType determineDefaultAccessType() {
for ( ClassDetails candidate = classDetails; candidate != null; candidate = candidate.getSuperClass() ) {
if ( ( candidate.getSuperClass() == null || Object.class.getName().equals( candidate.getSuperClass().getName() ) )
&& ( candidate.hasAnnotationUsage( Entity.class ) || candidate.hasAnnotationUsage( MappedSuperclass.class ) )
&& candidate.hasAnnotationUsage( Access.class ) ) {
return AccessType.getAccessStrategy( candidate.getAnnotationUsage( Access.class ).getEnum( "value" ) );
&& ( candidate.hasDirectAnnotationUsage( Entity.class ) || candidate.hasDirectAnnotationUsage( MappedSuperclass.class ) )
&& candidate.hasDirectAnnotationUsage( Access.class ) ) {
return AccessType.getAccessStrategy( candidate.getDirectAnnotationUsage( Access.class ).value() );
}
}
// Guess from identifier.
@ -270,19 +270,19 @@ public class InheritanceState {
for ( ClassDetails candidate = classDetails;
candidate != null && !Object.class.getName().equals( candidate.getName() );
candidate = candidate.getSuperClass() ) {
if ( candidate.hasAnnotationUsage( Entity.class ) || candidate.hasAnnotationUsage( MappedSuperclass.class ) ) {
if ( candidate.hasDirectAnnotationUsage( Entity.class ) || candidate.hasDirectAnnotationUsage( MappedSuperclass.class ) ) {
for ( MethodDetails method : candidate.getMethods() ) {
if ( method.getMethodKind() != MethodDetails.MethodKind.GETTER ) {
continue;
}
if ( method.hasAnnotationUsage( Id.class ) || method.hasAnnotationUsage( EmbeddedId.class ) ) {
if ( method.hasDirectAnnotationUsage( Id.class ) || method.hasDirectAnnotationUsage( EmbeddedId.class ) ) {
return AccessType.PROPERTY;
}
}
for ( FieldDetails field : candidate.getFields() ) {
if ( field.hasAnnotationUsage( Id.class ) || field.hasAnnotationUsage( EmbeddedId.class ) ) {
if ( field.hasDirectAnnotationUsage( Id.class ) || field.hasDirectAnnotationUsage( EmbeddedId.class ) ) {
return AccessType.FIELD;
}
}

View File

@ -20,7 +20,6 @@ import org.hibernate.mapping.List;
import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.usertype.UserCollectionType;
@ -50,7 +49,7 @@ public class ListBinder extends CollectionBinder {
}
@Override
public void setSqlOrderBy(AnnotationUsage<OrderBy> orderByAnn) {
public void setSqlOrderBy(OrderBy orderByAnn) {
if ( orderByAnn != null ) {
throw new AnnotationException( "A collection of type 'List' is annotated '@OrderBy'" );
}

View File

@ -34,7 +34,6 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
import org.hibernate.models.internal.ClassTypeDetailsImpl;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails;
@ -112,7 +111,7 @@ public class MapBinder extends CollectionBinder {
private void makeOneToManyMapKeyColumnNullableIfNotInProperty(MemberDetails property) {
final Map map = (Map) this.collection;
if ( map.isOneToMany() && property.hasAnnotationUsage( MapKeyColumn.class ) ) {
if ( map.isOneToMany() && property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {
final Value indexValue = map.getIndex();
if ( indexValue.getColumnSpan() != 1 ) {
throw new AssertionFailure( "Map key mapped by @MapKeyColumn does not have 1 column" );
@ -234,9 +233,9 @@ public class MapBinder extends CollectionBinder {
private static String getKeyType(MemberDetails property) {
//target has priority over reflection for the map key type
//JPA 2 has priority
final AnnotationUsage<MapKeyClass> mapKeyClassAnn = property.getAnnotationUsage( MapKeyClass.class );
final MapKeyClass mapKeyClassAnn = property.getDirectAnnotationUsage( MapKeyClass.class );
final Class<?> target = mapKeyClassAnn != null
? mapKeyClassAnn.getClassDetails( "value" ).toJavaClass()
? mapKeyClassAnn.value()
: void.class;
return void.class.equals( target ) ? property.getMapKeyType().getName() : target.getName();
}
@ -290,16 +289,16 @@ public class MapBinder extends CollectionBinder {
}
private void handleForeignKey(MemberDetails property, ManyToOne element) {
final AnnotationUsage<ForeignKey> foreignKey = getMapKeyForeignKey( property );
final ForeignKey foreignKey = getMapKeyForeignKey( property );
if ( foreignKey != null ) {
final ConstraintMode constraintMode = foreignKey.getEnum( "value" );
final ConstraintMode constraintMode = foreignKey.value();
if ( constraintMode == ConstraintMode.NO_CONSTRAINT
|| constraintMode == ConstraintMode.PROVIDER_DEFAULT && getBuildingContext().getBuildingOptions().isNoConstraintByDefault() ) {
element.disableForeignKey();
}
else {
element.setForeignKeyName( nullIfEmpty( foreignKey.getString( "name" ) ) );
element.setForeignKeyDefinition( nullIfEmpty( foreignKey.getString( "foreignKeyDefinition" ) ) );
element.setForeignKeyName( nullIfEmpty( foreignKey.name() ) );
element.setForeignKeyDefinition( nullIfEmpty( foreignKey.foreignKeyDefinition() ) );
}
}
}
@ -378,7 +377,7 @@ public class MapBinder extends CollectionBinder {
accessType,
//TODO be smart with isNullable
true,
new EntityBinder(),
new EntityBinder( buildingContext ),
false,
false,
true,
@ -401,10 +400,9 @@ public class MapBinder extends CollectionBinder {
MemberDetails property,
TypeDetails returnedClass,
MetadataBuildingContext context) {
final AnnotationUsage<MapKeyCompositeType> compositeType = property.getAnnotationUsage( MapKeyCompositeType.class );
final MapKeyCompositeType compositeType = property.getDirectAnnotationUsage( MapKeyCompositeType.class );
if ( compositeType != null ) {
final ClassDetails compositeTypeImplDetails = compositeType.getClassDetails( "value" );
return compositeTypeImplDetails.toJavaClass();
return compositeType.value();
}
if ( returnedClass != null ) {
@ -414,28 +412,30 @@ public class MapBinder extends CollectionBinder {
return null;
}
private AnnotationUsage<jakarta.persistence.ForeignKey> getMapKeyForeignKey(MemberDetails property) {
final AnnotationUsage<MapKeyJoinColumns> mapKeyJoinColumns = property.getAnnotationUsage( MapKeyJoinColumns.class );
final AnnotationUsage<MapKeyJoinColumn> mapKeyJoinColumn = property.getSingleAnnotationUsage( MapKeyJoinColumn.class );
private jakarta.persistence.ForeignKey getMapKeyForeignKey(MemberDetails property) {
final MapKeyJoinColumns mapKeyJoinColumns = property.getDirectAnnotationUsage( MapKeyJoinColumns.class );
if ( mapKeyJoinColumns != null ) {
return mapKeyJoinColumns.getNestedUsage( "foreignKey" );
return mapKeyJoinColumns.foreignKey();
}
else if ( mapKeyJoinColumn != null ) {
return mapKeyJoinColumn.getNestedUsage( "foreignKey" );
final MapKeyJoinColumn mapKeyJoinColumn = property.getDirectAnnotationUsage( MapKeyJoinColumn.class );
if ( mapKeyJoinColumn != null ) {
return mapKeyJoinColumn.foreignKey();
}
else {
return null;
}
}
private boolean mappingDefinedAttributeOverrideOnMapKey(MemberDetails property) {
if ( property.hasAnnotationUsage( AttributeOverride.class ) ) {
return namedMapKey( property.getAnnotationUsage( AttributeOverride.class ) );
final AttributeOverride overrideAnn = property.getDirectAnnotationUsage( AttributeOverride.class );
if ( overrideAnn != null ) {
return namedMapKey( overrideAnn );
}
if ( property.hasAnnotationUsage( AttributeOverrides.class ) ) {
final AnnotationUsage<AttributeOverrides> annotations = property.getAnnotationUsage( AttributeOverrides.class );
for ( AnnotationUsage<AttributeOverride> attributeOverride : annotations.<AnnotationUsage<AttributeOverride>>getList( "value" ) ) {
if ( namedMapKey( attributeOverride ) ) {
final AttributeOverrides overridesAnn = property.getDirectAnnotationUsage( AttributeOverrides.class );
if ( overridesAnn != null ) {
for ( AttributeOverride nestedAnn : overridesAnn.value() ) {
if ( namedMapKey( nestedAnn ) ) {
return true;
}
}
@ -443,8 +443,8 @@ public class MapBinder extends CollectionBinder {
return false;
}
private boolean namedMapKey(AnnotationUsage<AttributeOverride> annotation) {
return annotation.getString( "name" ).startsWith( "key." );
private boolean namedMapKey(AttributeOverride annotation) {
return annotation.name().startsWith( "key." );
}
private Value createFormulatedValue(

View File

@ -1,162 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.MutableAnnotationUsage;
import jakarta.persistence.CheckConstraint;
import jakarta.persistence.Column;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.MapKeyJoinColumn;
import static org.hibernate.boot.models.internal.AnnotationUsageHelper.applyAttributeIfSpecified;
import static org.hibernate.boot.models.internal.AnnotationUsageHelper.applyStringAttributeIfSpecified;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings({ "ClassExplicitlyAnnotation" })
public class MapKeyJoinColumnDelegator implements JoinColumn {
private final MapKeyJoinColumn column;
public MapKeyJoinColumnDelegator(AnnotationUsage<MapKeyJoinColumn> column) {
this( column.toAnnotation() );
}
public MapKeyJoinColumnDelegator(MapKeyJoinColumn column) {
this.column = column;
}
public static MutableAnnotationUsage<JoinColumn> fromMapKeyJoinColumn(
AnnotationUsage<MapKeyJoinColumn> mapKeyJoinColumn,
MemberDetails attributeMember,
MetadataBuildingContext context) {
final MutableAnnotationUsage<JoinColumn> joinColumn = JpaAnnotations.JOIN_COLUMN.createUsage( context.getMetadataCollector().getSourceModelBuildingContext() );
applyStringAttributeIfSpecified(
"name",
mapKeyJoinColumn.getAttributeValue( "name" ),
joinColumn
);
applyStringAttributeIfSpecified(
"table",
mapKeyJoinColumn.getAttributeValue( "table" ),
joinColumn
);
applyAttributeIfSpecified(
"unique",
mapKeyJoinColumn.getAttributeValue( "unique" ),
joinColumn
);
applyAttributeIfSpecified(
"nullable",
mapKeyJoinColumn.getAttributeValue( "nullable" ),
joinColumn
);
applyAttributeIfSpecified(
"insertable",
mapKeyJoinColumn.getAttributeValue( "insertable" ),
joinColumn
);
applyStringAttributeIfSpecified(
"referencedColumnName",
mapKeyJoinColumn.getAttributeValue( "referencedColumnName" ),
joinColumn
);
applyStringAttributeIfSpecified(
"columnDefinition",
mapKeyJoinColumn.getAttributeValue( "columnDefinition" ),
joinColumn
);
applyStringAttributeIfSpecified(
"options",
mapKeyJoinColumn.getAttributeValue( "options" ),
joinColumn
);
// joinColumn.setAttributeValue( "comment", mapKeyJoinColumn.getAttributeValue( "comment" ) );
applyAttributeIfSpecified(
"foreignKey",
mapKeyJoinColumn.getAttributeValue( "foreignKey" ),
joinColumn
);
return joinColumn;
}
@Override
public String name() {
return column.name();
}
@Override
public String referencedColumnName() {
return column.referencedColumnName();
}
@Override
public boolean unique() {
return column.unique();
}
@Override
public boolean nullable() {
return column.nullable();
}
@Override
public boolean insertable() {
return column.insertable();
}
@Override
public boolean updatable() {
return column.updatable();
}
@Override
public String columnDefinition() {
return column.columnDefinition();
}
@Override
public String options() {
return column.options();
}
@Override
public String table() {
return column.table();
}
@Override
public ForeignKey foreignKey() {
return column.foreignKey();
}
@Override
public CheckConstraint[] check() {
return new CheckConstraint[0];
}
@Override
public String comment() {
return "";
}
@Override
public Class<? extends Annotation> annotationType() {
return Column.class;
}
}

View File

@ -26,8 +26,6 @@ import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SortableValue;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.type.ForeignKeyDirection;
@ -105,7 +103,7 @@ public class OneToOneSecondPass implements SecondPass {
value.setConstrained( !optional );
value.setForeignKeyType( getForeignKeyDirection() );
bindForeignKeyNameAndDefinition( value, property, property.getAnnotationUsage( ForeignKey.class ), buildingContext );
bindForeignKeyNameAndDefinition( value, property, property.getDirectAnnotationUsage( ForeignKey.class ), buildingContext );
final PropertyBinder binder = new PropertyBinder();
binder.setName( propertyName );
@ -116,9 +114,9 @@ public class OneToOneSecondPass implements SecondPass {
binder.setBuildingContext( buildingContext );
binder.setHolder( propertyHolder );
final AnnotationUsage<LazyGroup> lazyGroupAnnotation = property.getAnnotationUsage( LazyGroup.class );
final LazyGroup lazyGroupAnnotation = property.getDirectAnnotationUsage( LazyGroup.class );
if ( lazyGroupAnnotation != null ) {
binder.setLazyGroup( lazyGroupAnnotation.getString( "value" ) );
binder.setLazyGroup( lazyGroupAnnotation.value() );
}
final Property result = binder.makeProperty();

View File

@ -9,6 +9,7 @@ package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.hibernate.AnnotationException;
@ -32,6 +33,7 @@ import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitUniqueKeyNameSource;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
@ -42,6 +44,7 @@ import org.hibernate.generator.BeforeExecutionGenerator;
import org.hibernate.generator.EventType;
import org.hibernate.generator.EventTypeSets;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.GeneratorCreator;
@ -55,18 +58,15 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.AnnotationDescriptor;
import org.hibernate.models.spi.AnnotationDescriptorRegistry;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableScope;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.jboss.logging.Logger;
import jakarta.persistence.Basic;
@ -107,7 +107,6 @@ import static org.hibernate.boot.model.internal.ToOneBinder.bindOneToOne;
import static org.hibernate.boot.model.naming.Identifier.toIdentifier;
import static org.hibernate.id.IdentifierGeneratorHelper.getForeignId;
import static org.hibernate.internal.util.StringHelper.qualify;
import static org.hibernate.internal.util.collections.CollectionHelper.combine;
/**
* A stateful binder responsible for creating {@link Property} objects.
@ -139,6 +138,10 @@ public class PropertyBinder {
private boolean toMany;
private String referencedEntityName;
protected SourceModelBuildingContext getSourceModelContext() {
return buildingContext.getMetadataCollector().getSourceModelBuildingContext();
}
public void setReferencedEntityName(String referencedEntityName) {
this.referencedEntityName = referencedEntityName;
}
@ -286,17 +289,29 @@ public class PropertyBinder {
@SuppressWarnings({"rawtypes", "unchecked"})
private void callAttributeBinders(Property property, Map<String, PersistentClass> persistentClasses) {
for ( AnnotationUsage<?> binderAnnotationUsage : memberDetails.getMetaAnnotated( AttributeBinderType.class ) ) {
final AttributeBinderType binderType = binderAnnotationUsage.getAnnotationType().getAnnotation( AttributeBinderType.class );
final List<? extends Annotation> metaAnnotatedTargets = memberDetails.getMetaAnnotated(
AttributeBinderType.class,
getSourceModelContext()
);
if ( CollectionHelper.isEmpty( metaAnnotatedTargets ) ) {
return;
}
final AnnotationDescriptorRegistry descriptorRegistry = getSourceModelContext().getAnnotationDescriptorRegistry();
for ( int i = 0; i < metaAnnotatedTargets.size(); i++ ) {
final Annotation metaAnnotatedTarget = metaAnnotatedTargets.get( i );
final AnnotationDescriptor<? extends Annotation> metaAnnotatedDescriptor = descriptorRegistry.getDescriptor( metaAnnotatedTarget.annotationType() );
final AttributeBinderType binderTypeAnn = metaAnnotatedDescriptor.getDirectAnnotationUsage( AttributeBinderType.class );
try {
final AttributeBinder binder = binderType.binder().getConstructor().newInstance();
final AttributeBinder binder = binderTypeAnn.binder().getConstructor().newInstance();
final PersistentClass persistentClass = entityBinder != null
? entityBinder.getPersistentClass()
: persistentClasses.get( holder.getEntityName() );
binder.bind( binderAnnotationUsage.toAnnotation(), buildingContext, persistentClass, property );
binder.bind( metaAnnotatedTarget, buildingContext, persistentClass, property );
}
catch ( Exception e ) {
throw new AnnotationException( "error processing @AttributeBinderType annotation '" + binderAnnotationUsage.getAnnotationType() + "'", e );
throw new AnnotationException( "error processing @AttributeBinderType annotation '" + metaAnnotatedDescriptor.getAnnotationType().getName() + "'", e );
}
}
}
@ -394,21 +409,21 @@ public class PropertyBinder {
}
}
private Class<? extends EmbeddableInstantiator> resolveCustomInstantiator(MemberDetails property, ClassDetails embeddableClass) {
if ( property.hasAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class ) ) {
final AnnotationUsage<org.hibernate.annotations.EmbeddableInstantiator> annotationUsage = property.getAnnotationUsage(
org.hibernate.annotations.EmbeddableInstantiator.class );
return annotationUsage.getClassDetails( "value" ).toJavaClass();
private Class<? extends EmbeddableInstantiator> resolveCustomInstantiator(
MemberDetails property,
ClassDetails embeddableClass) {
final org.hibernate.annotations.EmbeddableInstantiator onEmbedded = property.getDirectAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
if ( onEmbedded != null ) {
return onEmbedded.value();
}
else if ( embeddableClass.hasAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class ) ) {
final AnnotationUsage<org.hibernate.annotations.EmbeddableInstantiator> annotationUsage = embeddableClass.getAnnotationUsage(
org.hibernate.annotations.EmbeddableInstantiator.class );
return annotationUsage.getClassDetails( "value" ).toJavaClass();
final org.hibernate.annotations.EmbeddableInstantiator onEmbeddable = embeddableClass.getDirectAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
if ( onEmbeddable != null ) {
return onEmbeddable.value();
}
else {
return null;
}
}
//used when the value is provided and the binding is done elsewhere
public Property makeProperty() {
@ -443,10 +458,13 @@ public class PropertyBinder {
* Returns the value generation strategy for the given property, if any.
*/
private GeneratorCreator getValueGenerationFromAnnotations(MemberDetails property) {
final BeanContainer beanContainer = beanContainer( buildingContext );
GeneratorCreator creator = null;
for ( AnnotationUsage<?> usage : property.getAllAnnotationUsages() ) {
final GeneratorCreator candidate = generatorCreator( property, usage, beanContainer );
final List<? extends Annotation> metaAnnotatedTargets = property.getMetaAnnotated(
ValueGenerationType.class,
getSourceModelContext()
);
for ( Annotation metaAnnotatedTarget : metaAnnotatedTargets ) {
final GeneratorCreator candidate = generatorCreator( property, metaAnnotatedTarget, beanContainer( buildingContext ) );
if ( candidate != null ) {
if ( creator != null ) {
throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
@ -463,12 +481,12 @@ public class PropertyBinder {
private void handleLob(Property property) {
if ( this.memberDetails != null ) {
// HHH-4635 -- needed for dialect-specific property ordering
property.setLob( this.memberDetails.hasAnnotationUsage( Lob.class ) );
property.setLob( this.memberDetails.hasDirectAnnotationUsage( Lob.class ) );
}
}
private void handleMutability(Property property) {
if ( this.memberDetails != null && this.memberDetails.hasAnnotationUsage( Immutable.class ) ) {
if ( this.memberDetails != null && this.memberDetails.hasDirectAnnotationUsage( Immutable.class ) ) {
updatable = false;
}
property.setInsertable( insertable );
@ -507,14 +525,14 @@ public class PropertyBinder {
private void handleNaturalId(Property property) {
if ( this.memberDetails != null && entityBinder != null ) {
final AnnotationUsage<NaturalId> naturalId = this.memberDetails.getAnnotationUsage( NaturalId.class );
final NaturalId naturalId = this.memberDetails.getDirectAnnotationUsage( NaturalId.class );
if ( naturalId != null ) {
if ( !entityBinder.isRootEntity() ) {
throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
+ "' belongs to an entity subclass and may not be annotated '@NaturalId'" +
" (only a property of a root '@Entity' or a '@MappedSuperclass' may be a '@NaturalId')" );
}
if ( !naturalId.getBoolean( "mutable" ) ) {
if ( !naturalId.mutable() ) {
updatable = false;
}
property.setNaturalIdentifier( true );
@ -527,9 +545,9 @@ public class PropertyBinder {
if ( value instanceof Collection ) {
property.setOptimisticLocked( ((Collection) value).isOptimisticLocked() );
}
else if ( this.memberDetails != null && this.memberDetails.hasAnnotationUsage( OptimisticLock.class ) ) {
final AnnotationUsage<OptimisticLock> optimisticLock = this.memberDetails.getAnnotationUsage( OptimisticLock.class );
final boolean excluded = optimisticLock.getBoolean( "excluded" );
else if ( this.memberDetails != null && this.memberDetails.hasDirectAnnotationUsage( OptimisticLock.class ) ) {
final OptimisticLock optimisticLock = this.memberDetails.getDirectAnnotationUsage( OptimisticLock.class );
final boolean excluded = optimisticLock.excluded();
validateOptimisticLock( excluded );
property.setOptimisticLocked( !excluded );
}
@ -540,15 +558,15 @@ public class PropertyBinder {
private void validateOptimisticLock(boolean excluded) {
if ( excluded ) {
if ( memberDetails.hasAnnotationUsage( Version.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( Version.class ) ) {
throw new AnnotationException("Property '" + qualify( holder.getPath(), name )
+ "' is annotated '@OptimisticLock(excluded=true)' and '@Version'" );
}
if ( memberDetails.hasAnnotationUsage( Id.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( Id.class ) ) {
throw new AnnotationException("Property '" + qualify( holder.getPath(), name )
+ "' is annotated '@OptimisticLock(excluded=true)' and '@Id'" );
}
if ( memberDetails.hasAnnotationUsage( EmbeddedId.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( EmbeddedId.class ) ) {
throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
+ "' is annotated '@OptimisticLock(excluded=true)' and '@EmbeddedId'" );
}
@ -613,7 +631,7 @@ public class PropertyBinder {
else {
inFlightPropertyDataList.add( propertyAnnotatedElement );
}
if ( element.hasAnnotationUsage( MapsId.class ) ) {
if ( element.hasDirectAnnotationUsage( MapsId.class ) ) {
context.getMetadataCollector().addPropertyAnnotatedWithMapsId( ownerType.determineRawClass(), propertyAnnotatedElement );
}
@ -621,8 +639,8 @@ public class PropertyBinder {
}
private static void checkIdProperty(MemberDetails property, PropertyData propertyData) {
final AnnotationUsage<Id> incomingIdProperty = property.getAnnotationUsage( Id.class );
final AnnotationUsage<Id> existingIdProperty = propertyData.getAttributeMember().getAnnotationUsage( Id.class );
final Id incomingIdProperty = property.getDirectAnnotationUsage( Id.class );
final Id existingIdProperty = propertyData.getAttributeMember().getDirectAnnotationUsage( Id.class );
if ( incomingIdProperty != null && existingIdProperty == null ) {
throw new MappingException(
String.format(
@ -645,11 +663,12 @@ public class PropertyBinder {
//TODO support true/false/default on the property instead of present / not present
//TODO is @Column mandatory?
//TODO add method support
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) {
if ( element.hasAnnotationUsage( Id.class ) && element.hasAnnotationUsage( Column.class ) ) {
final String columnName = element.getAnnotationUsage( Column.class ).getString( "name" );
if ( element.hasDirectAnnotationUsage( Id.class ) && element.hasDirectAnnotationUsage( Column.class ) ) {
final String columnName = element.getDirectAnnotationUsage( Column.class ).name();
declaringClass.forEachField( (index, fieldDetails) -> {
if ( !element.hasAnnotationUsage( MapsId.class ) && isJoinColumnPresent( columnName, element ) ) {
if ( !element.hasDirectAnnotationUsage( MapsId.class ) && isJoinColumnPresent( columnName, element, sourceModelContext ) ) {
//create a PropertyData for the specJ property holding the mapping
context.getMetadataCollector().addPropertyAnnotatedWithMapsIdSpecj(
ownerType.determineRawClass(),
@ -671,12 +690,15 @@ public class PropertyBinder {
}
}
private static boolean isJoinColumnPresent(String columnName, MemberDetails property) {
private static boolean isJoinColumnPresent(String columnName, MemberDetails property, SourceModelBuildingContext modelContext) {
//The detection of a configured individual JoinColumn differs between Annotation
//and XML configuration processing.
final List<AnnotationUsage<JoinColumn>> joinColumnAnnotations = property.getRepeatedAnnotationUsages( JoinColumn.class );
for ( AnnotationUsage<JoinColumn> joinColumnAnnotation : joinColumnAnnotations ) {
if ( joinColumnAnnotation.getString( "name" ).equals( columnName ) ) {
final JoinColumn[] joinColumnAnnotations = property.getRepeatedAnnotationUsages(
JpaAnnotations.JOIN_COLUMN,
modelContext
);
for ( JoinColumn joinColumnAnnotation : joinColumnAnnotations ) {
if ( joinColumnAnnotation.name().equals( columnName ) ) {
return true;
}
}
@ -684,8 +706,8 @@ public class PropertyBinder {
}
static boolean hasIdAnnotation(MemberDetails element) {
return element.hasAnnotationUsage( Id.class )
|| element.hasAnnotationUsage( EmbeddedId.class );
return element.hasDirectAnnotationUsage( Id.class )
|| element.hasDirectAnnotationUsage( EmbeddedId.class );
}
/**
@ -724,7 +746,7 @@ public class PropertyBinder {
}
final MemberDetails property = inferredData.getAttributeMember();
if ( property.hasAnnotationUsage( Parent.class ) ) {
if ( property.hasDirectAnnotationUsage( Parent.class ) ) {
handleParentProperty( propertyHolder, inferredData, property );
}
else {
@ -803,9 +825,9 @@ public class PropertyBinder {
propertyBinder.setInheritanceStatePerClass( inheritanceStatePerClass );
propertyBinder.setId( !entityBinder.isIgnoreIdAnnotations() && hasIdAnnotation( property ) );
final AnnotationUsage<LazyGroup> lazyGroupAnnotation = property.getAnnotationUsage( LazyGroup.class );
final LazyGroup lazyGroupAnnotation = property.getDirectAnnotationUsage( LazyGroup.class );
if ( lazyGroupAnnotation != null ) {
propertyBinder.setLazyGroup( lazyGroupAnnotation.getString( "value" ) );
propertyBinder.setLazyGroup( lazyGroupAnnotation.value() );
}
final AnnotatedJoinColumns joinColumns = columnsBuilder.getJoinColumns();
@ -929,26 +951,31 @@ public class PropertyBinder {
}
private static boolean isVersion(MemberDetails property) {
return property.hasAnnotationUsage( Version.class );
return property.hasDirectAnnotationUsage( Version.class );
}
private static boolean isOneToOne(MemberDetails property) {
return property.hasAnnotationUsage( OneToOne.class );
return property.hasDirectAnnotationUsage( OneToOne.class );
}
private static boolean isManyToOne(MemberDetails property) {
return property.hasAnnotationUsage( ManyToOne.class );
return property.hasDirectAnnotationUsage( ManyToOne.class );
}
private static boolean isAny(MemberDetails property) {
return property.hasAnnotationUsage( Any.class );
return property.hasDirectAnnotationUsage( Any.class );
}
private static boolean isCollection(MemberDetails property) {
return property.hasAnnotationUsage( OneToMany.class )
|| property.hasAnnotationUsage( ManyToMany.class )
|| property.hasAnnotationUsage( ElementCollection.class )
|| property.hasAnnotationUsage( ManyToAny.class );
return property.hasDirectAnnotationUsage( OneToMany.class )
|| property.hasDirectAnnotationUsage( ManyToMany.class )
|| property.hasDirectAnnotationUsage( ElementCollection.class )
|| property.hasDirectAnnotationUsage( ManyToAny.class );
}
private static boolean isForcePersist(MemberDetails property) {
return property.hasDirectAnnotationUsage( MapsId.class )
|| property.hasDirectAnnotationUsage( Id.class );
}
private static void bindVersionProperty(
@ -1267,13 +1294,13 @@ public class PropertyBinder {
* @apiNote Poorly named to a degree. The intention is really whether non-optional is explicit
*/
private static boolean isExplicitlyOptional(MemberDetails attributeMember) {
final AnnotationUsage<Basic> basicAnn = attributeMember.getAnnotationUsage( Basic.class );
final Basic basicAnn = attributeMember.getDirectAnnotationUsage( Basic.class );
if ( basicAnn == null ) {
// things are optional (nullable) by default. If there is no annotation, that cannot be altered
return true;
}
return basicAnn.getBoolean( "optional" );
return basicAnn.optional();
}
/**
@ -1281,9 +1308,9 @@ public class PropertyBinder {
* account whether it is primitive?
*/
public static boolean isOptional(MemberDetails attributeMember, PropertyHolder propertyHolder) {
final AnnotationUsage<Basic> basicAnn = attributeMember.getAnnotationUsage( Basic.class );
final Basic basicAnn = attributeMember.getDirectAnnotationUsage( Basic.class );
if ( basicAnn != null ) {
return basicAnn.getBoolean( "optional" );
return basicAnn.optional();
}
if ( attributeMember.isArray() ) {
@ -1302,8 +1329,8 @@ public class PropertyBinder {
}
private static boolean isLazy(MemberDetails property) {
final AnnotationUsage<Basic> annotationUsage = property.getAnnotationUsage( Basic.class );
return annotationUsage != null && annotationUsage.getEnum( "fetch" ) == LAZY;
final Basic annotationUsage = property.getDirectAnnotationUsage( Basic.class );
return annotationUsage != null && annotationUsage.fetch() == LAZY;
}
private static void addIndexes(
@ -1312,7 +1339,7 @@ public class PropertyBinder {
AnnotatedColumns columns,
AnnotatedJoinColumns joinColumns) {
//process indexes after everything: in second pass, many to one has to be done before indexes
final AnnotationUsage<Index> index = property.getAnnotationUsage( Index.class );
final Index index = property.getDirectAnnotationUsage( Index.class );
if ( index == null ) {
return;
}
@ -1341,13 +1368,12 @@ public class PropertyBinder {
// For now, simply ensure consistent naming.
// TODO: AFAIK, there really isn't a reason for these UKs to be created
// on the SecondPass. This whole area should go away...
final AnnotationUsage<NaturalId> naturalId = property.getAnnotationUsage( NaturalId.class );
final NaturalId naturalId = property.getDirectAnnotationUsage( NaturalId.class );
if ( naturalId != null ) {
final Database database = context.getMetadataCollector().getDatabase();
final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions().getImplicitNamingStrategy();
if ( joinColumns != null ) {
final Identifier name =
implicitNamingStrategy.determineUniqueKeyName( new ImplicitUniqueKeyNameSource() {
final Identifier name = implicitNamingStrategy.determineUniqueKeyName( new ImplicitUniqueKeyNameSource() {
@Override
public Identifier getTableName() {
return joinColumns.getTable().getNameIdentifier();
@ -1374,8 +1400,7 @@ public class PropertyBinder {
}
}
else {
final Identifier name =
implicitNamingStrategy.determineUniqueKeyName(new ImplicitUniqueKeyNameSource() {
final Identifier name = implicitNamingStrategy.determineUniqueKeyName(new ImplicitUniqueKeyNameSource() {
@Override
public Identifier getTableName() {
return columns.getTable().getNameIdentifier();
@ -1407,14 +1432,15 @@ public class PropertyBinder {
private static Class<? extends CompositeUserType<?>> resolveCompositeUserType(
PropertyData inferredData,
MetadataBuildingContext context) {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final MemberDetails attributeMember = inferredData.getAttributeMember();
final TypeDetails classOrElementType = inferredData.getClassOrElementType();
final ClassDetails returnedClass = classOrElementType.determineRawClass();
if ( attributeMember != null ) {
final AnnotationUsage<CompositeType> compositeType = attributeMember.locateAnnotationUsage( CompositeType.class );
final CompositeType compositeType = attributeMember.locateAnnotationUsage( CompositeType.class, sourceModelContext );
if ( compositeType != null ) {
return compositeType.getClassDetails( "value" ).toJavaClass();
return compositeType.value();
}
final Class<? extends CompositeUserType<?>> compositeUserType = resolveTimeZoneStorageCompositeUserType( attributeMember, returnedClass, context );
if ( compositeUserType != null ) {
@ -1443,24 +1469,36 @@ public class PropertyBinder {
throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData )
+ "' belongs to an '@IdClass' and may not be annotated '@Id' or '@EmbeddedId'" );
}
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final MemberDetails idAttributeMember = inferredData.getAttributeMember();
final List<AnnotationUsage<? extends Annotation>> idGeneratorAnnotations = idAttributeMember.getMetaAnnotated( IdGeneratorType.class );
final List<AnnotationUsage<? extends Annotation>> generatorAnnotations = idAttributeMember.getMetaAnnotated( ValueGenerationType.class );
final List<? extends Annotation> idGeneratorAnnotations = idAttributeMember.getMetaAnnotated( IdGeneratorType.class, sourceModelContext );
final List<? extends Annotation> generatorAnnotations = idAttributeMember.getMetaAnnotated( ValueGenerationType.class, sourceModelContext );
removeIdGenerators( generatorAnnotations, idGeneratorAnnotations );
if ( idGeneratorAnnotations.size() + generatorAnnotations.size() > 1 ) {
throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData )
+ "' has too many generator annotations " + combine( idGeneratorAnnotations, generatorAnnotations ) );
throw new AnnotationException( String.format(
Locale.ROOT,
"Property `%s` has too many generator annotations : %s",
getPath( propertyHolder, inferredData ),
CollectionHelper.combineUntyped( idGeneratorAnnotations, generatorAnnotations )
) );
}
if ( !idGeneratorAnnotations.isEmpty() ) {
final AnnotationUsage annotation = idGeneratorAnnotations.get(0);
idValue.setCustomIdGeneratorCreator( identifierGeneratorCreator( idAttributeMember, annotation,
idValue, beanContainer( context ) ) );
idValue.setCustomIdGeneratorCreator( identifierGeneratorCreator(
idAttributeMember,
idGeneratorAnnotations.get(0),
idValue,
beanContainer( context )
) );
}
else if ( !generatorAnnotations.isEmpty() ) {
// idValue.setCustomGeneratorCreator( generatorCreator( idAttributeMember, generatorAnnotation ) );
throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData )
+ "' is annotated '" + generatorAnnotations.get(0).getAnnotationType()
+ "' which is not an '@IdGeneratorType'" );
throw new AnnotationException( String.format(
Locale.ROOT,
"Property '%s' is annotated `%s` which is not an `@IdGeneratorType`",
getPath( propertyHolder, inferredData ),
generatorAnnotations.get(0).annotationType()
) );
}
else {
final ClassDetails entityClass = inferredData.getClassOrElementType().determineRawClass();
@ -1479,12 +1517,11 @@ public class PropertyBinder {
// collection methods as those proxies do not implement hashcode/equals and even a simple `a.equals(a)` will return `false`.
// Instead, we will check the annotation types, since generator annotations should not be "repeatable" we should have only
// at most one annotation for a generator:
// todo (jpa32) : is this still necessary with s/hibernate-common-annotations/hibernate-models?
private static void removeIdGenerators(
List<AnnotationUsage<? extends Annotation>> generatorAnnotations,
List<AnnotationUsage<? extends Annotation>> idGeneratorAnnotations) {
for ( AnnotationUsage<? extends Annotation> id : idGeneratorAnnotations ) {
generatorAnnotations.removeIf( gen -> gen.getAnnotationType().equals( id.getAnnotationType() ) );
List<? extends Annotation> generatorAnnotations,
List<? extends Annotation> idGeneratorAnnotations) {
for ( Annotation id : idGeneratorAnnotations ) {
generatorAnnotations.removeIf( gen -> gen.annotationType().equals( id.annotationType() ) );
}
}
}

View File

@ -29,7 +29,6 @@ import org.hibernate.boot.spi.AccessType;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.FieldDetails;
import org.hibernate.models.spi.MemberDetails;
@ -179,9 +178,9 @@ public class PropertyContainer {
// Check fields...
for ( int i = 0; i < fields.size(); i++ ) {
final FieldDetails fieldDetails = fields.get( i );
final AnnotationUsage<Access> localAccessAnnotation = fieldDetails.getAnnotationUsage( Access.class );
final Access localAccessAnnotation = fieldDetails.getDirectAnnotationUsage( Access.class );
if ( localAccessAnnotation == null
|| localAccessAnnotation.getEnum( "value" ) != jakarta.persistence.AccessType.FIELD ) {
|| localAccessAnnotation.value() != jakarta.persistence.AccessType.FIELD ) {
continue;
}
persistentAttributeMap.put( fieldDetails.getName(), fieldDetails );
@ -190,9 +189,9 @@ public class PropertyContainer {
// Check getters...
for ( int i = 0; i < getters.size(); i++ ) {
final MethodDetails getterDetails = getters.get( i );
final AnnotationUsage<Access> localAccessAnnotation = getterDetails.getAnnotationUsage( Access.class );
final Access localAccessAnnotation = getterDetails.getDirectAnnotationUsage( Access.class );
if ( localAccessAnnotation == null
|| localAccessAnnotation.getEnum( "value" ) != jakarta.persistence.AccessType.PROPERTY ) {
|| localAccessAnnotation.value() != jakarta.persistence.AccessType.PROPERTY ) {
continue;
}
@ -218,7 +217,7 @@ public class PropertyContainer {
// Check record components...
for ( int i = 0; i < recordComponents.size(); i++ ) {
final RecordComponentDetails componentDetails = recordComponents.get( i );
final AnnotationUsage<Access> localAccessAnnotation = componentDetails.getAnnotationUsage( Access.class );
final Access localAccessAnnotation = componentDetails.getDirectAnnotationUsage( Access.class );
if ( localAccessAnnotation == null ) {
continue;
}
@ -330,65 +329,60 @@ public class PropertyContainer {
private AccessType determineLocalClassDefinedAccessStrategy() {
AccessType classDefinedAccessType = AccessType.DEFAULT;
final AnnotationUsage<Access> access = classDetails.getAnnotationUsage( Access.class );
final Access access = classDetails.getDirectAnnotationUsage( Access.class );
if ( access != null ) {
classDefinedAccessType = AccessType.getAccessStrategy( access.getEnum( "value" ) );
classDefinedAccessType = AccessType.getAccessStrategy( access.value() );
}
return classDefinedAccessType;
}
private static boolean discoverTypeWithoutReflection(ClassDetails classDetails, MemberDetails memberDetails) {
if ( memberDetails.hasAnnotationUsage( Target.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( Target.class ) ) {
return true;
}
if ( memberDetails.hasAnnotationUsage( Basic.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( Basic.class ) ) {
return true;
}
if ( memberDetails.hasAnnotationUsage( Type.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( Type.class ) ) {
return true;
}
if ( memberDetails.hasAnnotationUsage( JavaType.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( JavaType.class ) ) {
return true;
}
final AnnotationUsage<OneToOne> oneToOneAnn = memberDetails.getAnnotationUsage( OneToOne.class );
final OneToOne oneToOneAnn = memberDetails.getDirectAnnotationUsage( OneToOne.class );
if ( oneToOneAnn != null ) {
final ClassDetails targetEntity = oneToOneAnn.getClassDetails( "targetEntity" );
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
return oneToOneAnn.targetEntity() != void.class;
}
final AnnotationUsage<OneToMany> oneToManyAnn = memberDetails.getAnnotationUsage( OneToMany.class );
final OneToMany oneToManyAnn = memberDetails.getDirectAnnotationUsage( OneToMany.class );
if ( oneToManyAnn != null ) {
final ClassDetails targetEntity = oneToManyAnn.getClassDetails( "targetEntity" );
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
return oneToManyAnn.targetEntity() != void.class;
}
final AnnotationUsage<ManyToOne> manToOneAnn = memberDetails.getAnnotationUsage( ManyToOne.class );
if ( manToOneAnn != null ) {
final ClassDetails targetEntity = manToOneAnn.getClassDetails( "targetEntity" );
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
final ManyToOne manyToOneAnn = memberDetails.getDirectAnnotationUsage( ManyToOne.class );
if ( manyToOneAnn != null ) {
return manyToOneAnn.targetEntity() != void.class;
}
final AnnotationUsage<ManyToMany> manToManyAnn = memberDetails.getAnnotationUsage( ManyToMany.class );
if ( manToManyAnn != null ) {
final ClassDetails targetEntity = manToManyAnn.getClassDetails( "targetEntity" );
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
final ManyToMany manyToManyAnn = memberDetails.getDirectAnnotationUsage( ManyToMany.class );
if ( manyToManyAnn != null ) {
return manyToManyAnn.targetEntity() != void.class;
}
if ( memberDetails.hasAnnotationUsage( Any.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( Any.class ) ) {
return true;
}
final AnnotationUsage<ManyToAny> manToAnyAnn = memberDetails.getAnnotationUsage( ManyToAny.class );
final ManyToAny manToAnyAnn = memberDetails.getDirectAnnotationUsage( ManyToAny.class );
if ( manToAnyAnn != null ) {
return true;
}
else if ( memberDetails.hasAnnotationUsage( JdbcTypeCode.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( JdbcTypeCode.class ) ) {
return true;
}
@ -403,7 +397,7 @@ public class PropertyContainer {
private static boolean mustBeSkipped(MemberDetails memberDetails) {
//TODO make those hardcoded tests more portable (through the bytecode provider?)
return memberDetails.hasAnnotationUsage( Transient.class )
return memberDetails.hasDirectAnnotationUsage( Transient.class )
|| (memberDetails.getType() != null && "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( memberDetails.getType().getName() ) );
}
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.boot.model.internal;
import java.util.List;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.mapping.Join;
@ -15,7 +13,6 @@ import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
@ -65,22 +62,22 @@ public interface PropertyHolder {
/**
* return null if the column is not overridden, or an array of column if true
*/
List<AnnotationUsage<Column>> getOverriddenColumn(String propertyName);
Column[] getOverriddenColumn(String propertyName);
/**
* return null if the column is not overridden, or an array of column if true
*/
List<AnnotationUsage<JoinColumn>> getOverriddenJoinColumn(String propertyName);
JoinColumn[] getOverriddenJoinColumn(String propertyName);
/**
* return null if hte foreign key is not overridden, or the foreign key if true
*/
default AnnotationUsage<ForeignKey> getOverriddenForeignKey(String propertyName) {
default ForeignKey getOverriddenForeignKey(String propertyName) {
// todo: does this necessarily need to be a default method?
return null;
}
AnnotationUsage<ColumnTransformer> getOverriddenColumnTransformer(String logicalColumnName);
ColumnTransformer getOverriddenColumnTransformer(String logicalColumnName);
/**
* return
@ -88,13 +85,13 @@ public interface PropertyHolder {
* - the join table if not overridden,
* - the overridden join table otherwise
*/
AnnotationUsage<JoinTable> getJoinTable(MemberDetails attributeMember);
JoinTable getJoinTable(MemberDetails attributeMember);
String getEntityName();
Join addJoin(AnnotationUsage<JoinTable> joinTableAnn, boolean noDelayInPkColumnCreation);
Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation);
Join addJoin(AnnotationUsage<JoinTable> joinTable, Table table, boolean noDelayInPkColumnCreation);
Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation);
boolean isInIdClass();

View File

@ -13,8 +13,8 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.models.internal.ClassTypeDetailsImpl;
import org.hibernate.models.internal.dynamic.DynamicClassDetails;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails;
@ -63,9 +63,9 @@ public class PropertyInferredData implements PropertyData {
AccessType jpaAccessType = AccessType.DEFAULT;
AnnotationUsage<Access> access = propertyMember.getAnnotationUsage( Access.class );
Access access = propertyMember.getDirectAnnotationUsage( Access.class );
if ( access != null ) {
jpaAccessType = AccessType.getAccessStrategy( access.getEnum( "value" ) );
jpaAccessType = AccessType.getAccessStrategy( access.value() );
}
if ( jpaAccessType != AccessType.DEFAULT ) {
@ -81,12 +81,12 @@ public class PropertyInferredData implements PropertyData {
@Override
public TypeDetails getPropertyType() throws MappingException {
final AnnotationUsage<org.hibernate.boot.internal.Target> targetAnnotation = propertyMember.getAnnotationUsage( org.hibernate.boot.internal.Target.class );
if ( targetAnnotation != null ) {
final String targetName = targetAnnotation.getString( "value" );
final SourceModelBuildingContext sourceModelBuildingContext = buildingContext
.getMetadataCollector()
final org.hibernate.boot.internal.Target targetAnnotation = propertyMember.getDirectAnnotationUsage( org.hibernate.boot.internal.Target.class );
final SourceModelBuildingContext sourceModelContext = buildingContext.getMetadataCollector()
.getSourceModelBuildingContext();
if ( targetAnnotation != null ) {
final String targetName = targetAnnotation.value();
final SourceModelBuildingContext sourceModelBuildingContext = sourceModelContext;
final ClassDetails classDetails = sourceModelBuildingContext.getClassDetailsRegistry().resolveClassDetails(
targetName,
name -> new DynamicClassDetails( targetName, sourceModelBuildingContext )
@ -94,22 +94,31 @@ public class PropertyInferredData implements PropertyData {
return new ClassTypeDetailsImpl( classDetails, TypeDetails.Kind.CLASS );
}
final AnnotationUsage<Target> legacyTargetAnnotation = propertyMember.getAnnotationUsage( Target.class );
final Target legacyTargetAnnotation = propertyMember.getDirectAnnotationUsage( Target.class );
if ( legacyTargetAnnotation != null ) {
return new ClassTypeDetailsImpl( legacyTargetAnnotation.getClassDetails( "value" ), TypeDetails.Kind.CLASS );
return resolveLegacyTargetAnnotation( legacyTargetAnnotation, sourceModelContext );
}
return propertyMember.resolveRelativeType( ownerType );
}
private static ClassTypeDetailsImpl resolveLegacyTargetAnnotation(
Target legacyTargetAnnotation,
SourceModelBuildingContext sourceModelContext) {
final ClassDetailsRegistry classDetailsRegistry = sourceModelContext.getClassDetailsRegistry();
final ClassDetails targetClassDetails = classDetailsRegistry.resolveClassDetails( legacyTargetAnnotation.value().getName() );
return new ClassTypeDetailsImpl( targetClassDetails, TypeDetails.Kind.CLASS );
}
@Override
public TypeDetails getClassOrElementType() throws MappingException {
final AnnotationUsage<org.hibernate.boot.internal.Target> annotationUsage = propertyMember.getAnnotationUsage( org.hibernate.boot.internal.Target.class );
if ( annotationUsage != null ) {
final String targetName = annotationUsage.getString( "value" );
final SourceModelBuildingContext sourceModelBuildingContext = buildingContext
.getMetadataCollector()
.getSourceModelBuildingContext();
final org.hibernate.boot.internal.Target annotationUsage = propertyMember.getDirectAnnotationUsage( org.hibernate.boot.internal.Target.class );
if ( annotationUsage != null ) {
final String targetName = annotationUsage.value();
final ClassDetails classDetails = sourceModelBuildingContext.getClassDetailsRegistry().resolveClassDetails(
targetName,
name -> new DynamicClassDetails( targetName, sourceModelBuildingContext )
@ -117,9 +126,9 @@ public class PropertyInferredData implements PropertyData {
return new ClassTypeDetailsImpl( classDetails, TypeDetails.Kind.CLASS );
}
final AnnotationUsage<Target> legacyAnnotationUsage = propertyMember.getAnnotationUsage( Target.class );
if ( legacyAnnotationUsage != null ) {
return new ClassTypeDetailsImpl( legacyAnnotationUsage.getClassDetails( "value" ), TypeDetails.Kind.CLASS );
final Target legacyTargetAnnotation = propertyMember.getDirectAnnotationUsage( Target.class );
if ( legacyTargetAnnotation != null ) {
return resolveLegacyTargetAnnotation( legacyTargetAnnotation, sourceModelBuildingContext );
}
return propertyMember.resolveRelativeAssociatedType( ownerType );
@ -127,9 +136,15 @@ public class PropertyInferredData implements PropertyData {
@Override
public ClassDetails getClassOrPluralElement() throws MappingException {
final AnnotationUsage<Target> targetAnnotationUsage = propertyMember.getAnnotationUsage( Target.class );
if ( targetAnnotationUsage != null ) {
return targetAnnotationUsage.getClassDetails( "value" );
final org.hibernate.boot.internal.Target xmlTarget = propertyMember.getDirectAnnotationUsage( org.hibernate.boot.internal.Target.class );
if ( xmlTarget != null ) {
return buildingContext.getMetadataCollector().getClassDetailsRegistry().getClassDetails( xmlTarget.value() );
}
final Target legacyTarget = propertyMember.getDirectAnnotationUsage( Target.class );
if ( legacyTarget != null ) {
final String targetName = legacyTarget.value().getName();
return buildingContext.getMetadataCollector().getClassDetailsRegistry().getClassDetails( targetName );
}
if ( propertyMember.isPlural() ) {

View File

@ -7,6 +7,7 @@
package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.function.Supplier;
@ -22,6 +23,9 @@ import org.hibernate.annotations.SQLSelect;
import org.hibernate.boot.internal.NamedHqlQueryDefinitionImpl;
import org.hibernate.boot.internal.NamedProcedureCallDefinitionImpl;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.annotations.internal.NamedStoredProcedureQueryJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.QueryHintJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.StoredProcedureParameterJpaAnnotation;
import org.hibernate.boot.query.NamedHqlQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinition;
import org.hibernate.boot.query.NamedProcedureCallDefinition;
@ -30,11 +34,10 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.models.internal.util.StringHelper;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MutableAnnotationUsage;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.query.sql.internal.ParameterParser;
import org.hibernate.query.sql.spi.ParameterRecognizer;
@ -42,6 +45,8 @@ import org.hibernate.type.BasicType;
import org.jboss.logging.Logger;
import jakarta.persistence.CacheRetrieveMode;
import jakarta.persistence.CacheStoreMode;
import jakarta.persistence.NamedNativeQuery;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NamedStoredProcedureQuery;
@ -67,15 +72,15 @@ public abstract class QueryBinder {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, QueryBinder.class.getName());
public static void bindQuery(
AnnotationUsage<NamedQuery> namedQuery,
NamedQuery namedQuery,
MetadataBuildingContext context,
boolean isDefault) {
if ( namedQuery == null ) {
return;
}
final String queryName = namedQuery.getString( "name" );
final String queryString = namedQuery.getString( "query" );
final String queryName = namedQuery.name();
final String queryString = namedQuery.query();
if ( queryName.isEmpty() ) {
throw new AnnotationException( "Class or package level '@NamedQuery' annotation must specify a 'name'" );
@ -85,11 +90,11 @@ public abstract class QueryBinder {
LOG.debugf( "Binding named query: %s => %s", queryName, queryString );
}
final QueryHintDefinition hints = new QueryHintDefinition( queryName, namedQuery.getList( "hints" ) );
final QueryHintDefinition hints = new QueryHintDefinition( queryName, namedQuery.hints() );
final NamedHqlQueryDefinition<?> queryMapping = new NamedHqlQueryDefinitionImpl.Builder<>( queryName )
.setHqlString( queryString )
.setResultClass( loadClass( namedQuery.getClassDetails( "resultClass" ), context ) )
.setResultClass( (Class<Object>) namedQuery.resultClass() )
.setCacheable( hints.getCacheability() )
.setCacheMode( hints.getCacheMode() )
.setCacheRegion( hints.getString( HibernateHints.HINT_CACHE_REGION ) )
@ -119,28 +124,27 @@ public abstract class QueryBinder {
}
public static void bindNativeQuery(
AnnotationUsage<NamedNativeQuery> namedNativeQuery,
NamedNativeQuery namedNativeQuery,
MetadataBuildingContext context,
boolean isDefault) {
if ( namedNativeQuery == null ) {
return;
}
final String registrationName = namedNativeQuery.getString( "name" );
final String queryString = namedNativeQuery.getString( "query" );
final String registrationName = namedNativeQuery.name();
final String queryString = namedNativeQuery.query();
if ( registrationName.isEmpty() ) {
throw new AnnotationException( "Class or package level '@NamedNativeQuery' annotation must specify a 'name'" );
}
final QueryHintDefinition hints = new QueryHintDefinition( registrationName, namedNativeQuery.getList( "hints" ) );
final QueryHintDefinition hints = new QueryHintDefinition( registrationName, namedNativeQuery.hints() );
final String resultSetMappingName = namedNativeQuery.getString( "resultSetMapping" );
final ClassDetails resultClassDetails = namedNativeQuery.getClassDetails( "resultClass" );
final Class<Object> resultClass = ClassDetails.VOID_CLASS_DETAILS == resultClassDetails
final String resultSetMappingName = namedNativeQuery.resultSetMapping();
final Class<?> resultClassDetails = namedNativeQuery.resultClass();
final Class<Object> resultClass = void.class == resultClassDetails
? null
: context.getBootstrapContext().getServiceRegistry().requireService( ClassLoaderService.class )
.classForName( resultClassDetails.getClassName() );
: (Class<Object>) resultClassDetails;
final NamedNativeQueryDefinition.Builder<?> builder = new NamedNativeQueryDefinition.Builder<>( registrationName )
.setSqlString( queryString )
@ -173,13 +177,13 @@ public abstract class QueryBinder {
public static void bindNativeQuery(
String name,
AnnotationUsage<SQLSelect> sqlSelect,
SQLSelect sqlSelect,
ClassDetails annotatedClass,
MetadataBuildingContext context) {
final NamedNativeQueryDefinition.Builder<?> builder = new NamedNativeQueryDefinition.Builder<>( name )
.setFlushMode( FlushMode.MANUAL )
.setSqlString( sqlSelect.getString( "sql" ) )
.setQuerySpaces( setOf( sqlSelect.getList( "querySpaces" ) ) );
.setSqlString( sqlSelect.sql() )
.setQuerySpaces( setOf( sqlSelect.querySpaces() ) );
if ( annotatedClass != null ) {
builder.setResultClass(
@ -188,10 +192,10 @@ public abstract class QueryBinder {
);
}
final AnnotationUsage<SqlResultSetMapping> resultSetMapping = sqlSelect.getNestedUsage( "resultSetMapping" );
if ( !resultSetMapping.getList( "columns" ).isEmpty()
|| !resultSetMapping.getList( "entities" ).isEmpty()
|| !resultSetMapping.getList( "classes" ).isEmpty() ) {
final SqlResultSetMapping resultSetMapping = sqlSelect.resultSetMapping();
if ( !ArrayHelper.isEmpty( resultSetMapping.columns() )
|| !ArrayHelper.isEmpty( resultSetMapping.entities() )
|| !ArrayHelper.isEmpty( resultSetMapping.classes() ) ) {
context.getMetadataCollector().addResultSetMapping( SqlResultSetMappingDescriptor.from( resultSetMapping, name ) );
builder.setResultSetMappingName( name );
}
@ -200,48 +204,47 @@ public abstract class QueryBinder {
}
public static void bindNativeQuery(
AnnotationUsage<org.hibernate.annotations.NamedNativeQuery> namedNativeQuery,
org.hibernate.annotations.NamedNativeQuery namedNativeQuery,
MetadataBuildingContext context) {
if ( namedNativeQuery == null ) {
return;
}
final String registrationName = namedNativeQuery.getString( "name" );
final String registrationName = namedNativeQuery.name();
//ResultSetMappingDefinition mappingDefinition = mappings.getJdbcValuesMappingProducer( queryAnn.resultSetMapping() );
if ( registrationName.isEmpty() ) {
throw new AnnotationException( "Class or package level '@NamedNativeQuery' annotation must specify a 'name'" );
}
final String resultSetMappingName = namedNativeQuery.getString( "resultSetMapping" );
final ClassDetails resultClassDetails = namedNativeQuery.getClassDetails( "resultClass" );
final Class<Object> resultClass = ClassDetails.VOID_CLASS_DETAILS == resultClassDetails
final String resultSetMappingName = namedNativeQuery.resultSetMapping();
final Class<?> resultClassDetails = namedNativeQuery.resultClass();
final Class<Object> resultClass = resultClassDetails == void.class
? null
: context.getBootstrapContext().getServiceRegistry().requireService( ClassLoaderService.class )
.classForName( resultClassDetails.getClassName() );
: (Class<Object>) resultClassDetails;
final Integer timeout = namedNativeQuery.getInteger( "timeout" );
final Integer fetchSize = namedNativeQuery.getInteger( "fetchSize" );
final Integer timeout = namedNativeQuery.timeout();
final Integer fetchSize = namedNativeQuery.fetchSize();
final List<String> querySpacesList = namedNativeQuery.getList( "querySpaces" );
final HashSet<String> querySpaces = new HashSet<>( determineProperSizing( querySpacesList.size() ) );
querySpaces.addAll( querySpacesList );
final String[] querySpacesList = namedNativeQuery.querySpaces();
final HashSet<String> querySpaces = new HashSet<>( determineProperSizing( querySpacesList.length ) );
Collections.addAll( querySpaces, querySpacesList );
final NamedNativeQueryDefinition.Builder<?> builder = new NamedNativeQueryDefinition.Builder<>( registrationName )
.setSqlString( namedNativeQuery.getString( "query" ) )
.setSqlString( namedNativeQuery.query() )
.setResultSetMappingName( resultSetMappingName )
.setResultClass( resultClass )
.setCacheable( namedNativeQuery.getBoolean( "cacheable" ) )
.setCacheRegion( nullIfEmpty( namedNativeQuery.getString( "cacheRegion" ) ) )
.setCacheMode( getCacheMode( namedNativeQuery ) )
.setCacheable( namedNativeQuery.cacheable() )
.setCacheRegion( nullIfEmpty( namedNativeQuery.cacheRegion() ) )
.setCacheMode( getCacheMode( namedNativeQuery.cacheRetrieveMode(), namedNativeQuery.cacheStoreMode(), namedNativeQuery.cacheMode() ) )
.setTimeout( timeout < 0 ? null : timeout )
.setFetchSize( fetchSize < 0 ? null : fetchSize )
.setFlushMode( getFlushMode( namedNativeQuery.getEnum( "flushMode" ) ) )
.setReadOnly( namedNativeQuery.getBoolean( "readOnly" ) )
.setFlushMode( getFlushMode( namedNativeQuery.flushMode() ) )
.setReadOnly( namedNativeQuery.readOnly() )
.setQuerySpaces( querySpaces )
.setComment( nullIfEmpty( namedNativeQuery.getString( "comment" ) ) );
.setComment( nullIfEmpty( namedNativeQuery.comment() ) );
if ( TRUE == namedNativeQuery.getBoolean( "callable" ) ) {
if ( TRUE == namedNativeQuery.callable() ) {
final NamedProcedureCallDefinition definition =
createStoredProcedure( builder, context, () -> illegalCallSyntax( namedNativeQuery ) );
context.getMetadataCollector().addNamedProcedureCallDefinition( definition );
@ -264,6 +267,12 @@ public abstract class QueryBinder {
}
}
/**
* Handles legacy cases where a named native query was used to specify a procedure call
*
* @deprecated User should use {@linkplain NamedStoredProcedureQuery} instead
*/
@Deprecated
public static NamedProcedureCallDefinition createStoredProcedure(
NamedNativeQueryDefinition.Builder<?> builder,
MetadataBuildingContext context,
@ -276,18 +285,22 @@ public abstract class QueryBinder {
final SourceModelBuildingContext sourceModelBuildingContext = context.getMetadataCollector()
.getSourceModelBuildingContext();
final MutableAnnotationUsage<NamedStoredProcedureQuery> nameStoredProcedureQueryAnn =
JpaAnnotations.NAMED_STORED_PROCEDURE_QUERY.createUsage( sourceModelBuildingContext );
nameStoredProcedureQueryAnn.setAttributeValue( "name", builder.getName() );
nameStoredProcedureQueryAnn.setAttributeValue( "procedureName", jdbcCall.callableName );
final NamedStoredProcedureQueryJpaAnnotation nameStoredProcedureQueryAnn = JpaAnnotations.NAMED_STORED_PROCEDURE_QUERY.createUsage( sourceModelBuildingContext );
nameStoredProcedureQueryAnn.name( builder.getName() );
nameStoredProcedureQueryAnn.procedureName( jdbcCall.callableName );
final List<AnnotationUsage<StoredProcedureParameter>> storedProcedureParameters = new ArrayList<>();
for ( String parameterName : jdbcCall.parameters ) {
final MutableAnnotationUsage<StoredProcedureParameter> storedProcedureParameterAnn =
JpaAnnotations.STORED_PROCEDURE_PARAMETER.createUsage( sourceModelBuildingContext );
storedProcedureParameterAnn.setAttributeValue( "name", parameterName );
storedProcedureParameterAnn.setAttributeValue( "mode", ParameterMode.IN );
final String typeName = builder.getParameterTypes().get( parameterName );
final StoredProcedureParameter[] parameters = new StoredProcedureParameter[jdbcCall.parameters.size()];
nameStoredProcedureQueryAnn.parameters( parameters );
for ( int i = 0; i < jdbcCall.parameters.size(); i++ ) {
final StoredProcedureParameterJpaAnnotation param = JpaAnnotations.STORED_PROCEDURE_PARAMETER.createUsage( sourceModelBuildingContext );
parameters[i] = param;
final String paramName = jdbcCall.parameters.get( i );
param.name( paramName );
param.mode( ParameterMode.IN );
final String typeName = builder.getParameterTypes().get( paramName );
final ClassDetails classDetails;
if ( StringHelper.isEmpty( typeName ) ) {
classDetails = ClassDetails.VOID_CLASS_DETAILS;
@ -297,89 +310,82 @@ public abstract class QueryBinder {
.getTypeConfiguration()
.getBasicTypeRegistry()
.getRegisteredType( typeName );
classDetails = storedProcedureParameterAnn.getClassDetails( registeredType.getJavaType().getName() );
classDetails = context.getMetadataCollector().getClassDetailsRegistry().getClassDetails( registeredType.getJavaType().getName() );
}
storedProcedureParameterAnn.setAttributeValue( "type", classDetails );
storedProcedureParameters.add( storedProcedureParameterAnn );
param.type( classDetails.toJavaClass() );
}
nameStoredProcedureQueryAnn.setAttributeValue( "parameters", storedProcedureParameters );
if ( builder.getResultSetMappingName() != null ) {
final List<String> resultSetMappings = new ArrayList<>( 1 );
resultSetMappings.add( builder.getResultSetMappingName() );
nameStoredProcedureQueryAnn.setAttributeValue( "resultSetMappings", resultSetMappings );
nameStoredProcedureQueryAnn.resultSetMappings( new String[] { builder.getResultSetMappingName() } );
}
final Class<?> resultClass = builder.getResultClass();
if ( resultClass != null ) {
final List<ClassDetails> resultClasses = new ArrayList<>( 1 );
final ClassDetails classDetails = nameStoredProcedureQueryAnn.getClassDetails( resultClass.getName() );
resultClasses.add( classDetails );
nameStoredProcedureQueryAnn.setAttributeValue( "resultClasses", resultClasses );
nameStoredProcedureQueryAnn.resultClasses( new Class[]{ builder.getResultClass() } );
}
final List<AnnotationUsage<QueryHint>> queryHints = new ArrayList<>();
final List<QueryHintJpaAnnotation> hints = new ArrayList<>();
if ( builder.getQuerySpaces() != null ) {
final MutableAnnotationUsage<QueryHint> queryHintAnn = JpaAnnotations.QUERY_HINT.createUsage( sourceModelBuildingContext );
queryHintAnn.setAttributeValue( "name", HibernateHints.HINT_NATIVE_SPACES );
queryHintAnn.setAttributeValue( "value", String.join( " ", builder.getQuerySpaces() ) );
queryHints.add( queryHintAnn );
final QueryHintJpaAnnotation hint = JpaAnnotations.QUERY_HINT.createUsage( sourceModelBuildingContext );
hint.name( HibernateHints.HINT_NATIVE_SPACES );
hint.value( String.join( " ", builder.getQuerySpaces() ) );
hints.add( hint );
}
if ( jdbcCall.resultParameter ) {
// Mark native queries that have a result parameter as callable functions
final MutableAnnotationUsage<QueryHint> queryHintAnn = JpaAnnotations.QUERY_HINT.createUsage( sourceModelBuildingContext );
queryHintAnn.setAttributeValue( "name", HibernateHints.HINT_CALLABLE_FUNCTION );
queryHintAnn.setAttributeValue( "value", "true" );
queryHints.add( queryHintAnn );
final QueryHintJpaAnnotation hint = JpaAnnotations.QUERY_HINT.createUsage( sourceModelBuildingContext );
hint.name( HibernateHints.HINT_CALLABLE_FUNCTION );
hint.value( "true" );
hints.add( hint );
}
nameStoredProcedureQueryAnn.setAttributeValue( "hints", queryHints );
nameStoredProcedureQueryAnn.hints( hints.toArray(QueryHint[]::new) );
return new NamedProcedureCallDefinitionImpl( nameStoredProcedureQueryAnn );
}
public static void bindQuery(
String name,
AnnotationUsage<HQLSelect> hqlSelect,
HQLSelect hqlSelect,
MetadataBuildingContext context) {
final NamedHqlQueryDefinition<?> hqlQueryDefinition = new NamedHqlQueryDefinition.Builder<>( name )
.setFlushMode( FlushMode.MANUAL )
.setHqlString( hqlSelect.getString( "query" ) )
.setHqlString( hqlSelect.query() )
.build();
context.getMetadataCollector().addNamedQuery( hqlQueryDefinition );
}
public static void bindQuery(
AnnotationUsage<org.hibernate.annotations.NamedQuery> namedQuery,
org.hibernate.annotations.NamedQuery namedQuery,
MetadataBuildingContext context) {
if ( namedQuery == null ) {
return;
}
final String registrationName = namedQuery.getString( "name" );
final String registrationName = namedQuery.name();
//ResultSetMappingDefinition mappingDefinition = mappings.getJdbcValuesMappingProducer( namedQuery.resultSetMapping() );
if ( registrationName.isEmpty() ) {
throw new AnnotationException( "Class or package level '@NamedQuery' annotation must specify a 'name'" );
}
final Integer timeout = namedQuery.getInteger( "timeout" );
final Integer fetchSize = namedQuery.getInteger( "fetchSize" );
final int timeout = namedQuery.timeout();
final int fetchSize = namedQuery.fetchSize();
final NamedHqlQueryDefinition.Builder<?> builder = new NamedHqlQueryDefinition.Builder<>( registrationName )
.setHqlString( namedQuery.getString( "query" ) )
.setResultClass( loadClass( namedQuery.getClassDetails( "resultClass" ), context ) )
.setCacheable( namedQuery.getBoolean( "cacheable" ) )
.setCacheRegion( nullIfEmpty( namedQuery.getString( "cacheRegion" ) ) )
.setCacheMode( getCacheMode( namedQuery ) )
.setHqlString( namedQuery.query() )
.setResultClass( (Class<Object>) namedQuery.resultClass() )
.setCacheable( namedQuery.cacheable() )
.setCacheRegion( nullIfEmpty( namedQuery.cacheRegion() ) )
.setCacheMode( getCacheMode( namedQuery.cacheRetrieveMode(), namedQuery.cacheStoreMode(), namedQuery.cacheMode() ) )
.setTimeout( timeout < 0 ? null : timeout )
.setFetchSize( fetchSize < 0 ? null : fetchSize )
.setFlushMode( getFlushMode( namedQuery.getEnum( "flushMode" ) ) )
.setReadOnly( namedQuery.getBoolean( "readOnly" ) )
.setComment( nullIfEmpty( namedQuery.getString( "comment" ) ) );
.setFlushMode( getFlushMode( namedQuery.flushMode() ) )
.setReadOnly( namedQuery.readOnly() )
.setComment( nullIfEmpty( namedQuery.comment() ) );
final NamedHqlQueryDefinitionImpl<?> hqlQueryDefinition = builder.build();
@ -390,13 +396,10 @@ public abstract class QueryBinder {
context.getMetadataCollector().addNamedQuery( hqlQueryDefinition );
}
private static CacheMode getCacheMode(AnnotationUsage<?> namedQuery) {
final CacheMode cacheMode = CacheMode.fromJpaModes(
namedQuery.getEnum( "cacheRetrieveMode" ),
namedQuery.getEnum( "cacheStoreMode" )
);
private static CacheMode getCacheMode(CacheRetrieveMode cacheRetrieveMode, CacheStoreMode cacheStoreMode, CacheModeType cacheModeType) {
final CacheMode cacheMode = CacheMode.fromJpaModes( cacheRetrieveMode, cacheStoreMode );
return cacheMode == null || cacheMode == CacheMode.NORMAL
? interpretCacheMode( namedQuery.getEnum( "cacheMode" ) )
? interpretCacheMode( cacheModeType )
: cacheMode;
}
@ -435,11 +438,11 @@ public abstract class QueryBinder {
}
public static void bindNamedStoredProcedureQuery(
AnnotationUsage<NamedStoredProcedureQuery> namedStoredProcedureQuery,
NamedStoredProcedureQuery namedStoredProcedureQuery,
MetadataBuildingContext context,
boolean isDefault) {
if ( namedStoredProcedureQuery != null ) {
if ( namedStoredProcedureQuery.getString( "name" ).isEmpty() ) {
if ( namedStoredProcedureQuery.name().isEmpty() ) {
throw new AnnotationException( "Class or package level '@NamedStoredProcedureQuery' annotation must specify a 'name'" );
}
@ -455,7 +458,7 @@ public abstract class QueryBinder {
}
public static void bindSqlResultSetMapping(
AnnotationUsage<SqlResultSetMapping> resultSetMappingAnn,
SqlResultSetMapping resultSetMappingAnn,
MetadataBuildingContext context,
boolean isDefault) {
//no need to handle inSecondPass
@ -543,8 +546,8 @@ public abstract class QueryBinder {
return i;
}
private static AnnotationException illegalCallSyntax(AnnotationUsage<org.hibernate.annotations.NamedNativeQuery> queryAnn) {
return new AnnotationException( "Callable 'NamedNativeQuery' named '" + queryAnn.getString( "name" )
private static AnnotationException illegalCallSyntax(org.hibernate.annotations.NamedNativeQuery queryAnn) {
return new AnnotationException( "Callable 'NamedNativeQuery' named '" + queryAnn.name()
+ "' does not use the JDBC call syntax" );
}
}

View File

@ -7,7 +7,6 @@
package org.hibernate.boot.model.internal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.hibernate.AnnotationException;
@ -23,7 +22,6 @@ import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jpa.HibernateHints;
import org.hibernate.jpa.LegacySpecHints;
import org.hibernate.jpa.SpecHints;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.LockModeType;
import jakarta.persistence.NamedQuery;
@ -38,15 +36,15 @@ public class QueryHintDefinition {
private final String queryName;
private final Map<String, Object> hintsMap;
public QueryHintDefinition(String queryName, final List<AnnotationUsage<QueryHint>> hints) {
public QueryHintDefinition(String queryName, final QueryHint[] hints) {
this.queryName = queryName;
if ( CollectionHelper.isEmpty( hints ) ) {
hintsMap = Collections.emptyMap();
}
else {
final Map<String, Object> hintsMap = mapOfSize( hints.size() );
for ( AnnotationUsage<QueryHint> hint : hints ) {
hintsMap.put( hint.getString( "name" ), hint.getString( "value" ) );
final Map<String, Object> hintsMap = mapOfSize( hints.length );
for ( QueryHint hint : hints ) {
hintsMap.put( hint.name(), hint.value() );
}
this.hintsMap = hintsMap;
}
@ -153,8 +151,8 @@ public class QueryHintDefinition {
}
}
public LockOptions determineLockOptions(AnnotationUsage<NamedQuery> namedQueryAnnotation) {
final LockModeType lockModeType = namedQueryAnnotation.getEnum( "lockMode" );
public LockOptions determineLockOptions(NamedQuery namedQueryAnnotation) {
final LockModeType lockModeType = namedQueryAnnotation.lockMode();
final Integer lockTimeoutHint = specLockTimeout();
final Boolean followOnLocking = getBooleanWrapper( HibernateHints.HINT_FOLLOW_ON_LOCKING );

View File

@ -12,7 +12,6 @@ import org.hibernate.MappingException;
import org.hibernate.boot.query.SqlResultSetMappingDescriptor;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.SqlResultSetMapping;
@ -22,11 +21,11 @@ import jakarta.persistence.SqlResultSetMapping;
public class ResultSetMappingSecondPass implements QuerySecondPass {
// private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ResultsetMappingSecondPass.class );
private final AnnotationUsage<SqlResultSetMapping> annotation;
private final SqlResultSetMapping annotation;
private final MetadataBuildingContext context;
private final boolean isDefault;
public ResultSetMappingSecondPass(AnnotationUsage<SqlResultSetMapping> annotation, MetadataBuildingContext context, boolean isDefault) {
public ResultSetMappingSecondPass(SqlResultSetMapping annotation, MetadataBuildingContext context, boolean isDefault) {
this.annotation = annotation;
this.context = context;
this.isDefault = isDefault;

View File

@ -13,7 +13,6 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Set;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.usertype.UserCollectionType;
@ -38,7 +37,7 @@ public class SetBinder extends CollectionBinder {
}
@Override
public void setSqlOrderBy(AnnotationUsage<OrderBy> orderByAnn) {
public void setSqlOrderBy(OrderBy orderByAnn) {
if ( orderByAnn != null ) {
super.setSqlOrderBy( orderByAnn );
}

View File

@ -21,7 +21,6 @@ import org.hibernate.metamodel.mapping.SoftDeletableModelPart;
import org.hibernate.metamodel.mapping.SoftDeleteMapping;
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
import org.hibernate.metamodel.mapping.internal.SoftDeleteMappingImpl;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression;
@ -45,19 +44,18 @@ public class SoftDeleteHelper {
/**
* Creates and binds the column and value for modeling the soft-delete in the database
*
* @param softDeleteConfigAnnotation The SoftDelete annotation
* @param softDeleteConfig The SoftDelete annotation
* @param target The thing which is to be soft-deleted
* @param table The table to which the soft-delete should be applied
* @param context The processing context for access to needed info and services
*/
public static void bindSoftDeleteIndicator(
AnnotationUsage<SoftDelete> softDeleteConfigAnnotation,
SoftDelete softDeleteConfig,
SoftDeletable target,
Table table,
MetadataBuildingContext context) {
assert softDeleteConfigAnnotation != null;
assert softDeleteConfig != null;
final SoftDelete softDeleteConfig = softDeleteConfigAnnotation.toAnnotation();
final BasicValue softDeleteIndicatorValue = createSoftDeleteIndicatorValue( softDeleteConfig, table, context );
final Column softDeleteIndicatorColumn = createSoftDeleteIndicatorColumn(
softDeleteConfig,

View File

@ -40,7 +40,6 @@ import org.hibernate.mapping.SortableValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.models.spi.AnnotationUsage;
import org.jboss.logging.Logger;
@ -76,8 +75,8 @@ public class TableBinder {
private String associatedEntity;
private String associatedJpaEntity;
private boolean isJPA2ElementCollection;
private List<AnnotationUsage<UniqueConstraint>> uniqueConstraints;
private List<AnnotationUsage<Index>> indexes;
private UniqueConstraint[] uniqueConstraints;
private Index[] indexes;
private String options;
public void setBuildingContext(MetadataBuildingContext buildingContext) {
@ -104,11 +103,11 @@ public class TableBinder {
isAbstract = anAbstract;
}
public void setUniqueConstraints(List<AnnotationUsage<UniqueConstraint>> uniqueConstraints) {
public void setUniqueConstraints(UniqueConstraint[] uniqueConstraints) {
this.uniqueConstraints = uniqueConstraints;
}
public void setJpaIndex(List<AnnotationUsage<Index>> indexes){
public void setJpaIndex(Index[] indexes){
this.indexes = indexes;
}
@ -441,7 +440,7 @@ public class TableBinder {
String catalog,
Identifier logicalName,
boolean isAbstract,
List<AnnotationUsage<UniqueConstraint>> uniqueConstraints,
UniqueConstraint[] uniqueConstraints,
MetadataBuildingContext buildingContext) {
return buildAndFillTable(
schema,
@ -462,7 +461,7 @@ public class TableBinder {
String catalog,
Identifier logicalName,
boolean isAbstract,
List<AnnotationUsage<UniqueConstraint>> uniqueConstraints,
UniqueConstraint[] uniqueConstraints,
MetadataBuildingContext buildingContext,
String subselect,
InFlightMetadataCollector.EntityTableXref denormalizedSuperTableXref) {
@ -485,8 +484,8 @@ public class TableBinder {
String catalog,
Identifier logicalName,
boolean isAbstract,
List<AnnotationUsage<UniqueConstraint>> uniqueConstraints,
List<AnnotationUsage<Index>> indexes,
UniqueConstraint[] uniqueConstraints,
Index[] indexes,
String options,
MetadataBuildingContext buildingContext,
String subselect,
@ -863,10 +862,10 @@ public class TableBinder {
}
}
static void addIndexes(Table table, List<AnnotationUsage<org.hibernate.annotations.Index>> indexes, MetadataBuildingContext context) {
for ( AnnotationUsage<org.hibernate.annotations.Index> indexUsage : indexes ) {
final String name = indexUsage.getString( "name" );
final String[] columnNames = indexUsage.<String>getList( "columnNames" ).toArray(new String[0]);
static void addIndexes(Table table, org.hibernate.annotations.Index[] indexes, MetadataBuildingContext context) {
for ( org.hibernate.annotations.Index indexUsage : indexes ) {
final String name = indexUsage.name();
final String[] columnNames = indexUsage.columnNames();
//no need to handle inSecondPass here since it is only called from EntityBinder
context.getMetadataCollector().addSecondPass( new IndexOrUniqueKeySecondPass(
@ -880,21 +879,21 @@ public class TableBinder {
static void addJpaIndexes(
Table table,
List<AnnotationUsage<jakarta.persistence.Index>> indexes,
jakarta.persistence.Index[] indexes,
MetadataBuildingContext context) {
new IndexBinder( context ).bindIndexes( table, indexes );
}
static void addTableCheck(
Table table,
List<AnnotationUsage<jakarta.persistence.CheckConstraint>> checkConstraintAnnotationUsages) {
jakarta.persistence.CheckConstraint[] checkConstraintAnnotationUsages) {
if ( CollectionHelper.isNotEmpty( checkConstraintAnnotationUsages ) ) {
for ( AnnotationUsage<jakarta.persistence.CheckConstraint> checkConstraintAnnotationUsage : checkConstraintAnnotationUsages ) {
for ( jakarta.persistence.CheckConstraint checkConstraintAnnotationUsage : checkConstraintAnnotationUsages ) {
table.addCheck(
new CheckConstraint(
checkConstraintAnnotationUsage.getString( "name" ),
checkConstraintAnnotationUsage.getString( "constraint" ),
checkConstraintAnnotationUsage.getString( "options" )
checkConstraintAnnotationUsage.name(),
checkConstraintAnnotationUsage.constraint(),
checkConstraintAnnotationUsage.options()
)
);
}

View File

@ -11,10 +11,8 @@ import java.time.OffsetTime;
import java.time.ZonedDateTime;
import org.hibernate.annotations.TimeZoneStorage;
import org.hibernate.annotations.TimeZoneStorageType;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails;
@ -78,7 +76,7 @@ public class TimeZoneStorageHelper {
}
static boolean useColumnForTimeZoneStorage(AnnotationTarget element, MetadataBuildingContext context) {
final AnnotationUsage<TimeZoneStorage> timeZoneStorage = element.getAnnotationUsage( TimeZoneStorage.class );
final TimeZoneStorage timeZoneStorage = element.getDirectAnnotationUsage( TimeZoneStorage.class );
if ( timeZoneStorage == null ) {
if ( element instanceof MemberDetails attributeMember ) {
return isTemporalWithTimeZoneClass( attributeMember.getType().getName() )
@ -90,7 +88,7 @@ public class TimeZoneStorageHelper {
}
}
else {
return switch ( timeZoneStorage.getEnum( "value", TimeZoneStorageType.class ) ) {
return switch ( timeZoneStorage.value() ) {
case COLUMN -> true;
// if the db has native support for timezones, we use that, not a column
case AUTO -> context.getBuildingOptions().getTimeZoneSupport() != NATIVE;

View File

@ -9,7 +9,6 @@ package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
import jakarta.persistence.Entity;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
@ -32,11 +31,12 @@ import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.Id;
@ -83,11 +83,11 @@ public class ToOneBinder {
MemberDetails property,
AnnotatedJoinColumns joinColumns,
PropertyBinder propertyBinder) {
final AnnotationUsage<ManyToOne> manyToOne = property.getAnnotationUsage( ManyToOne.class );
final ManyToOne manyToOne = property.getDirectAnnotationUsage( ManyToOne.class );
//check validity
if ( property.hasAnnotationUsage( Column.class )
|| property.hasAnnotationUsage( Columns.class ) ) {
if ( property.hasDirectAnnotationUsage( Column.class )
|| property.hasDirectAnnotationUsage( Columns.class ) ) {
throw new AnnotationException(
"Property '" + getPath( propertyHolder, inferredData )
+ "' is a '@ManyToOne' association and may not use '@Column' to specify column mappings (use '@JoinColumn' instead)"
@ -101,19 +101,19 @@ public class ToOneBinder {
);
}
final AnnotationUsage<Cascade> hibernateCascade = property.getAnnotationUsage( Cascade.class );
final AnnotationUsage<NotFound> notFound = property.getAnnotationUsage( NotFound.class );
final NotFoundAction notFoundAction = notFound == null ? null : notFound.getEnum( "action" );
matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, manyToOne.getEnum( "fetch" ) );
final AnnotationUsage<OnDelete> onDelete = property.getAnnotationUsage( OnDelete.class );
final AnnotationUsage<JoinTable> joinTable = propertyHolder.getJoinTable( property );
final Cascade hibernateCascade = property.getDirectAnnotationUsage( Cascade.class );
final NotFound notFound = property.getDirectAnnotationUsage( NotFound.class );
final NotFoundAction notFoundAction = notFound == null ? null : notFound.action();
matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, manyToOne.fetch() );
final OnDelete onDelete = property.getDirectAnnotationUsage( OnDelete.class );
final JoinTable joinTable = propertyHolder.getJoinTable( property );
bindManyToOne(
getCascadeStrategy( manyToOne.getList( "cascade" ), hibernateCascade, false, context ),
getCascadeStrategy( manyToOne.cascade(), hibernateCascade, false, context ),
joinColumns,
joinTable,
!isMandatory( manyToOne.getBoolean( "optional" ), property, notFoundAction ),
!isMandatory( manyToOne.optional(), property, notFoundAction ),
notFoundAction,
onDelete == null ? null : onDelete.getEnum( "action" ),
onDelete == null ? null : onDelete.action(),
getTargetEntity( inferredData, context ),
propertyHolder,
inferredData,
@ -144,14 +144,14 @@ public class ToOneBinder {
// the association is optional.
// @OneToOne(optional = true) with @PKJC makes the association optional.
return !optional
|| property.hasAnnotationUsage( Id.class )
|| property.hasAnnotationUsage( MapsId.class ) && notFoundAction != NotFoundAction.IGNORE;
|| property.hasDirectAnnotationUsage( Id.class )
|| property.hasDirectAnnotationUsage( MapsId.class ) && notFoundAction != NotFoundAction.IGNORE;
}
private static void bindManyToOne(
String cascadeStrategy,
AnnotatedJoinColumns joinColumns,
AnnotationUsage<JoinTable> joinTable,
JoinTable joinTable,
boolean optional,
NotFoundAction notFoundAction,
OnDeleteAction onDeleteAction,
@ -163,7 +163,7 @@ public class ToOneBinder {
boolean inSecondPass,
PropertyBinder propertyBinder,
MetadataBuildingContext context) {
if ( joinTable != null && !isEmpty( joinTable.getString( "name" ) ) ) {
if ( joinTable != null && !isEmpty( joinTable.name() ) ) {
final Join join = propertyHolder.addJoin( joinTable, false );
// TODO: if notFoundAction!=null should we call join.disableForeignKeyCreation() ?
for ( AnnotatedJoinColumn joinColumn : joinColumns.getJoinColumns() ) {
@ -178,7 +178,7 @@ public class ToOneBinder {
final org.hibernate.mapping.ManyToOne value =
new org.hibernate.mapping.ManyToOne( context, joinColumns.getTable() );
if ( joinTable != null && isEmpty( joinTable.getString( "name" ) ) ) {
if ( joinTable != null && isEmpty( joinTable.name() ) ) {
context.getMetadataCollector().addSecondPass( new ImplicitToOneJoinTableSecondPass(
propertyHolder,
inferredData,
@ -207,15 +207,15 @@ public class ToOneBinder {
}
}
if ( property.hasAnnotationUsage( MapsId.class ) ) {
final AnnotationUsage<MapsId> mapsId = property.getAnnotationUsage( MapsId.class );
if ( property.hasDirectAnnotationUsage( MapsId.class ) ) {
final MapsId mapsId = property.getDirectAnnotationUsage( MapsId.class );
final List<AnnotatedJoinColumn> joinColumnList = joinColumns.getJoinColumns();
//read only
for ( AnnotatedJoinColumn column : joinColumnList ) {
column.setInsertable( false );
column.setUpdatable( false );
}
joinColumns.setMapsId( mapsId.getString( "value" ) );
joinColumns.setMapsId( mapsId.value() );
}
final boolean hasSpecjManyToOne = handleSpecjSyntax( joinColumns, inferredData, context, property );
@ -259,7 +259,7 @@ public class ToOneBinder {
static boolean isTargetAnnotatedEntity(ClassDetails targetEntity, MemberDetails property, MetadataBuildingContext context) {
final ClassDetails target = isDefault( targetEntity, context ) ? property.getType().determineRawClass() : targetEntity;
return target.hasAnnotationUsage( Entity.class );
return target.hasDirectAnnotationUsage( Entity.class );
}
private static boolean handleSpecjSyntax(
@ -270,18 +270,18 @@ public class ToOneBinder {
//Make sure that JPA1 key-many-to-one columns are read only too
boolean hasSpecjManyToOne = false;
if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) {
final AnnotationUsage<JoinColumn> joinColumn = property.getAnnotationUsage( JoinColumn.class );
final JoinColumn joinColumn = property.getDirectAnnotationUsage( JoinColumn.class );
String columnName = "";
for ( MemberDetails prop : inferredData.getDeclaringClass().getFields() ) {
if ( prop.hasAnnotationUsage( Id.class ) && prop.hasAnnotationUsage( Column.class ) ) {
columnName = prop.getAnnotationUsage( Column.class ).getString( "name" );
if ( prop.hasDirectAnnotationUsage( Id.class ) && prop.hasDirectAnnotationUsage( Column.class ) ) {
columnName = prop.getDirectAnnotationUsage( Column.class ).name();
}
if ( property.hasAnnotationUsage( ManyToOne.class ) && joinColumn != null ) {
final String joinColumnName = joinColumn.getString( "name" );
if ( property.hasDirectAnnotationUsage( ManyToOne.class ) && joinColumn != null ) {
final String joinColumnName = joinColumn.name();
if ( StringHelper.isNotEmpty( joinColumnName )
&& joinColumnName.equals( columnName )
&& !property.hasAnnotationUsage( MapsId.class ) ) {
&& !property.hasDirectAnnotationUsage( MapsId.class ) ) {
hasSpecjManyToOne = true;
for ( AnnotatedJoinColumn column : columns.getJoinColumns() ) {
column.setInsertable( false );
@ -326,19 +326,19 @@ public class ToOneBinder {
propertyBinder.setMemberDetails( property );
propertyBinder.setToMany( true );
final AnnotationUsage<JoinColumn> joinColumn = property.getSingleAnnotationUsage( JoinColumn.class );
final AnnotationUsage<JoinColumns> joinColumns = property.getAnnotationUsage( JoinColumns.class );
final JoinColumn joinColumn = property.getDirectAnnotationUsage( JoinColumn.class );
final JoinColumns joinColumns = property.getDirectAnnotationUsage( JoinColumns.class );
propertyBinder.makePropertyAndBind().setOptional( optional && isNullable( joinColumns, joinColumn ) );
}
private static boolean isNullable(AnnotationUsage<JoinColumns> joinColumns, AnnotationUsage<JoinColumn> joinColumn) {
private static boolean isNullable(JoinColumns joinColumns, JoinColumn joinColumn) {
if ( joinColumn != null ) {
return joinColumn.getBoolean( "nullable" );
return joinColumn.nullable();
}
if ( joinColumns != null ) {
for ( AnnotationUsage<JoinColumn> column : joinColumns.<AnnotationUsage<JoinColumn>>getList( "value" ) ) {
if ( column.getBoolean( "nullable" ) ) {
for ( JoinColumn column : joinColumns.value() ) {
if ( column.nullable() ) {
return true;
}
}
@ -359,7 +359,7 @@ public class ToOneBinder {
}
private static void handleLazy(ToOne toOne, MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) {
if ( property.hasAnnotationUsage( NotFound.class ) ) {
if ( property.hasDirectAnnotationUsage( NotFound.class ) ) {
toOne.setLazy( false );
toOne.setUnwrapProxy( true );
}
@ -378,16 +378,17 @@ public class ToOneBinder {
PropertyData inferredData) {
final MetadataBuildingContext context = toOne.getBuildingContext();
final InFlightMetadataCollector collector = context.getMetadataCollector();
property.forEachAnnotationUsage( FetchProfileOverride.class, (usage) -> {
final SourceModelBuildingContext sourceModelContext = collector.getSourceModelBuildingContext();
property.forEachAnnotationUsage( FetchProfileOverride.class, sourceModelContext, (usage) -> {
collector.addSecondPass( new FetchSecondPass( usage, propertyHolder, inferredData.getPropertyName(), context ) );
} );
}
private static void handleFetch(ToOne toOne, MemberDetails property) {
final AnnotationUsage<Fetch> fetchAnnotationUsage = property.getAnnotationUsage( Fetch.class );
final Fetch fetchAnnotationUsage = property.getDirectAnnotationUsage( Fetch.class );
if ( fetchAnnotationUsage != null ) {
// Hibernate @Fetch annotation takes precedence
setHibernateFetchMode( toOne, property, fetchAnnotationUsage.getEnum( "value" ) );
setHibernateFetchMode( toOne, property, fetchAnnotationUsage.value() );
}
else {
toOne.setFetchMode( getFetchMode( getJpaFetchType( property ) ) );
@ -415,9 +416,9 @@ public class ToOneBinder {
private static boolean isEager(MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) {
final FetchType fetchType = getJpaFetchType( property );
final AnnotationUsage<LazyToOne> lazyToOneAnnotationUsage = property.getAnnotationUsage( LazyToOne.class );
final LazyToOne lazyToOneAnnotationUsage = property.getDirectAnnotationUsage( LazyToOne.class );
if ( lazyToOneAnnotationUsage != null ) {
final LazyToOneOption option = lazyToOneAnnotationUsage.getEnum( "value" );
final LazyToOneOption option = lazyToOneAnnotationUsage.value();
boolean eager = option == LazyToOneOption.FALSE;
if ( eager && fetchType == LAZY ) {
// conflicts with non-default setting
@ -432,13 +433,13 @@ public class ToOneBinder {
}
private static FetchType getJpaFetchType(MemberDetails property) {
final AnnotationUsage<ManyToOne> manyToOne = property.getAnnotationUsage( ManyToOne.class );
final AnnotationUsage<OneToOne> oneToOne = property.getAnnotationUsage( OneToOne.class );
final ManyToOne manyToOne = property.getDirectAnnotationUsage( ManyToOne.class );
final OneToOne oneToOne = property.getDirectAnnotationUsage( OneToOne.class );
if ( manyToOne != null ) {
return manyToOne.getEnum( "fetch" );
return manyToOne.fetch();
}
else if ( oneToOne != null ) {
return oneToOne.getEnum( "fetch" );
return oneToOne.fetch();
}
else {
throw new AssertionFailure("Define fetch strategy on a property not annotated with @OneToMany nor @OneToOne");
@ -454,11 +455,11 @@ public class ToOneBinder {
MemberDetails property,
AnnotatedJoinColumns joinColumns,
PropertyBinder propertyBinder) {
final AnnotationUsage<OneToOne> oneToOne = property.getAnnotationUsage( OneToOne.class );
final OneToOne oneToOne = property.getDirectAnnotationUsage( OneToOne.class );
//check validity
if ( property.hasAnnotationUsage( Column.class )
|| property.hasAnnotationUsage( Columns.class ) ) {
if ( property.hasDirectAnnotationUsage( Column.class )
|| property.hasDirectAnnotationUsage( Columns.class ) ) {
throw new AnnotationException(
"Property '" + getPath( propertyHolder, inferredData )
+ "' is a '@OneToOne' association and may not use '@Column' to specify column mappings"
@ -474,28 +475,28 @@ public class ToOneBinder {
}
//FIXME support a proper PKJCs
final boolean trueOneToOne = property.hasAnnotationUsage( PrimaryKeyJoinColumn.class )
|| property.hasAnnotationUsage( PrimaryKeyJoinColumns.class );
final AnnotationUsage<Cascade> hibernateCascade = property.getAnnotationUsage( Cascade.class );
final AnnotationUsage<NotFound> notFound = property.getAnnotationUsage( NotFound.class );
final NotFoundAction notFoundAction = notFound == null ? null : notFound.getEnum( "action" );
final boolean trueOneToOne = property.hasDirectAnnotationUsage( PrimaryKeyJoinColumn.class )
|| property.hasDirectAnnotationUsage( PrimaryKeyJoinColumns.class );
final Cascade hibernateCascade = property.getDirectAnnotationUsage( Cascade.class );
final NotFound notFound = property.getDirectAnnotationUsage( NotFound.class );
final NotFoundAction notFoundAction = notFound == null ? null : notFound.action();
matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, oneToOne.getEnum( "fetch" ) );
final AnnotationUsage<OnDelete> onDelete = property.getAnnotationUsage( OnDelete.class );
final AnnotationUsage<JoinTable> joinTable = propertyHolder.getJoinTable( property );
matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, oneToOne.fetch() );
final OnDelete onDelete = property.getDirectAnnotationUsage( OnDelete.class );
final JoinTable joinTable = propertyHolder.getJoinTable( property );
bindOneToOne(
getCascadeStrategy( oneToOne.getList( "cascade" ), hibernateCascade, oneToOne.getBoolean( "orphanRemoval" ), context ),
getCascadeStrategy( oneToOne.cascade(), hibernateCascade, oneToOne.orphanRemoval(), context ),
joinColumns,
joinTable,
!isMandatory( oneToOne.getBoolean( "optional" ), property, notFoundAction ),
getFetchMode( oneToOne.getEnum( "fetch" ) ),
!isMandatory( oneToOne.optional(), property, notFoundAction ),
getFetchMode( oneToOne.fetch() ),
notFoundAction,
onDelete == null ? null : onDelete.getEnum( "action" ),
onDelete == null ? null : onDelete.action(),
getTargetEntity( inferredData, context ),
property,
propertyHolder,
inferredData,
nullIfEmpty( oneToOne.getString( "mappedBy" ) ),
nullIfEmpty( oneToOne.mappedBy() ),
trueOneToOne,
isIdentifierMapper,
inSecondPass,
@ -507,7 +508,7 @@ public class ToOneBinder {
private static void bindOneToOne(
String cascadeStrategy,
AnnotatedJoinColumns joinColumns,
AnnotationUsage<JoinTable> joinTable,
JoinTable joinTable,
boolean optional,
FetchMode fetchMode,
NotFoundAction notFoundAction,
@ -606,46 +607,46 @@ public class ToOneBinder {
public static void bindForeignKeyNameAndDefinition(
SimpleValue value,
MemberDetails property,
AnnotationUsage<ForeignKey> foreignKey,
ForeignKey foreignKey,
MetadataBuildingContext context) {
if ( property.hasAnnotationUsage( NotFound.class ) ) {
if ( property.hasDirectAnnotationUsage( NotFound.class ) ) {
// supersedes all others
value.disableForeignKey();
}
else {
final AnnotationUsage<JoinColumn> joinColumn = property.getSingleAnnotationUsage( JoinColumn.class );
final AnnotationUsage<JoinColumns> joinColumns = property.getAnnotationUsage( JoinColumns.class );
final JoinColumn joinColumn = property.getDirectAnnotationUsage( JoinColumn.class );
final JoinColumns joinColumns = property.getDirectAnnotationUsage( JoinColumns.class );
final boolean noConstraintByDefault = context.getBuildingOptions().isNoConstraintByDefault();
if ( joinColumn != null && noConstraint( joinColumn.getNestedUsage( "foreignKey" ), noConstraintByDefault )
|| joinColumns != null && noConstraint( joinColumns.getNestedUsage( "foreignKey" ), noConstraintByDefault ) ) {
if ( joinColumn != null && noConstraint( joinColumn.foreignKey(), noConstraintByDefault )
|| joinColumns != null && noConstraint( joinColumns.foreignKey(), noConstraintByDefault ) ) {
value.disableForeignKey();
}
else {
final AnnotationUsage<org.hibernate.annotations.ForeignKey> fk =
property.getAnnotationUsage( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && isNotEmpty( fk.getString( "name" ) ) ) {
value.setForeignKeyName( fk.getString( "name" ) );
final org.hibernate.annotations.ForeignKey fk =
property.getDirectAnnotationUsage( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && isNotEmpty( fk.name() ) ) {
value.setForeignKeyName( fk.name() );
}
else {
if ( noConstraint( foreignKey, noConstraintByDefault ) ) {
value.disableForeignKey();
}
else if ( foreignKey != null ) {
value.setForeignKeyName( nullIfEmpty( foreignKey.getString( "name" ) ) );
value.setForeignKeyDefinition( nullIfEmpty( foreignKey.getString( "foreignKeyDefinition" ) ) );
value.setForeignKeyName( nullIfEmpty( foreignKey.name() ) );
value.setForeignKeyDefinition( nullIfEmpty( foreignKey.foreignKeyDefinition() ) );
}
else if ( noConstraintByDefault ) {
value.disableForeignKey();
}
else if ( joinColumns != null ) {
final AnnotationUsage<ForeignKey> joinColumnsForeignKey = joinColumns.getNestedUsage( "foreignKey" );
value.setForeignKeyName( nullIfEmpty( joinColumnsForeignKey.getString( "name" ) ) );
value.setForeignKeyDefinition( nullIfEmpty( joinColumnsForeignKey.getString( "foreignKeyDefinition" ) ) );
final ForeignKey joinColumnsForeignKey = joinColumns.foreignKey();
value.setForeignKeyName( nullIfEmpty( joinColumnsForeignKey.name() ) );
value.setForeignKeyDefinition( nullIfEmpty( joinColumnsForeignKey.foreignKeyDefinition() ) );
}
else if ( joinColumn != null ) {
final AnnotationUsage<ForeignKey> joinColumnForeignKey = joinColumn.getNestedUsage( "foreignKey" );
value.setForeignKeyName( nullIfEmpty( joinColumnForeignKey.getString( "name" ) ) );
value.setForeignKeyDefinition( nullIfEmpty( joinColumnForeignKey.getString( "foreignKeyDefinition" ) ) );
final ForeignKey joinColumnForeignKey = joinColumn.foreignKey();
value.setForeignKeyName( nullIfEmpty( joinColumnForeignKey.name() ) );
value.setForeignKeyDefinition( nullIfEmpty( joinColumnForeignKey.foreignKeyDefinition() ) );
}
}
}
@ -663,17 +664,18 @@ public class ToOneBinder {
}
public static ClassDetails getTargetEntity(PropertyData propertyData, MetadataBuildingContext context) {
return getTargetEntityClass( propertyData.getAttributeMember() );
return getTargetEntityClass( propertyData.getAttributeMember(), context );
}
private static ClassDetails getTargetEntityClass(MemberDetails property) {
final AnnotationUsage<ManyToOne> manyToOne = property.getAnnotationUsage( ManyToOne.class );
private static ClassDetails getTargetEntityClass(MemberDetails property, MetadataBuildingContext context) {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final ManyToOne manyToOne = property.getDirectAnnotationUsage( ManyToOne.class );
if ( manyToOne != null ) {
return manyToOne.getClassDetails( "targetEntity" );
return sourceModelContext.getClassDetailsRegistry().resolveClassDetails( manyToOne.targetEntity().getName() );
}
final AnnotationUsage<OneToOne> oneToOne = property.getAnnotationUsage( OneToOne.class );
final OneToOne oneToOne = property.getDirectAnnotationUsage( OneToOne.class );
if ( oneToOne != null ) {
return oneToOne.getClassDetails( "targetEntity" );
return sourceModelContext.getClassDetailsRegistry().resolveClassDetails( oneToOne.targetEntity().getName() );
}
throw new AssertionFailure( "Unexpected discovery of a targetEntity: " + property.getName() );
}

View File

@ -50,8 +50,8 @@ import org.hibernate.boot.model.source.internal.hbm.HbmMetadataSourceProcessorIm
import org.hibernate.boot.model.source.internal.hbm.MappingDocument;
import org.hibernate.boot.model.source.internal.hbm.ModelBinder;
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
import org.hibernate.boot.models.categorize.internal.DomainModelCategorizationCollector;
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper;
import org.hibernate.boot.models.internal.DomainModelCategorizationCollector;
import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult;
import org.hibernate.boot.models.xml.spi.XmlPreProcessor;
import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
@ -551,7 +551,7 @@ public class MetadataBuildingProcess {
//noinspection unchecked
annotationDescriptorRegistry.resolveDescriptor(
annotationClass,
(t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext.getAnnotationDescriptorRegistry() )
(t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext )
);
}

View File

@ -13,9 +13,7 @@ import java.util.Map;
import java.util.Set;
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
import org.hibernate.boot.jaxb.spi.Binding;
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
import org.hibernate.boot.model.convert.spi.ConverterRegistry;
import org.hibernate.boot.model.convert.spi.RegisteredConversion;
@ -24,7 +22,7 @@ import org.hibernate.boot.model.internal.InheritanceState;
import org.hibernate.boot.model.process.spi.ManagedResources;
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
import org.hibernate.boot.models.categorize.spi.FilterDefRegistration;
import org.hibernate.boot.models.spi.FilterDefRegistration;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware;
import org.hibernate.boot.spi.MetadataBuildingOptions;
@ -36,10 +34,6 @@ import org.jboss.logging.Logger;
import jakarta.persistence.Entity;
import jakarta.persistence.MappedSuperclass;
import static org.hibernate.boot.jaxb.SourceType.OTHER;
import static org.hibernate.models.spi.ClassDetails.VOID_CLASS_DETAILS;
import static org.hibernate.models.spi.ClassDetails.VOID_OBJECT_CLASS_DETAILS;
/**
* @author Steve Ebersole
*/
@ -75,15 +69,16 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
final ConverterRegistry converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
domainModelSource.getConversionRegistrations().forEach( (registration) -> {
final Class<?> domainType;
if ( registration.getExplicitDomainType() == VOID_CLASS_DETAILS || registration.getExplicitDomainType() == VOID_OBJECT_CLASS_DETAILS ) {
if ( registration.getExplicitDomainType() == void.class
|| registration.getExplicitDomainType() == Void.class ) {
domainType = void.class;
}
else {
domainType = classLoaderService.classForName( registration.getExplicitDomainType().getClassName() );
domainType = registration.getExplicitDomainType();
}
converterRegistry.addRegisteredConversion( new RegisteredConversion(
domainType,
classLoaderService.classForName( registration.getConverterType().getClassName() ),
registration.getConverterType(),
registration.isAutoApply(),
rootMetadataBuildingContext
) );
@ -234,7 +229,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
List<XClass> clazzHierarchy = new ArrayList<>();
for ( ClassDetails clazz : classes ) {
if ( clazz.hasAnnotationUsage( MappedSuperclass.class ) ) {
if ( clazz.hasDirectAnnotationUsage( MappedSuperclass.class ) ) {
if ( debug ) {
log.debugf(
"Skipping explicit MappedSuperclass %s, the class will be discovered analyzing the implementing class",
@ -253,8 +248,8 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
ClassDetails superClass = clazz.getSuperClass();
while ( superClass != null
&& !Object.class.getName().equals( superClass.getName() ) ) {
if ( superClass.hasAnnotationUsage( Entity.class )
|| superClass.hasAnnotationUsage( MappedSuperclass.class ) ) {
if ( superClass.hasDirectAnnotationUsage( Entity.class )
|| superClass.hasDirectAnnotationUsage( MappedSuperclass.class ) ) {
if ( orderedClasses.contains( superClass ) ) {
break;
}

View File

@ -10,9 +10,9 @@ import java.util.List;
import java.util.Set;
import org.hibernate.boot.internal.RootMappingDefaults;
import org.hibernate.boot.models.categorize.spi.ConversionRegistration;
import org.hibernate.boot.models.categorize.spi.ConverterRegistration;
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations;
import org.hibernate.boot.models.spi.ConversionRegistration;
import org.hibernate.boot.models.spi.ConverterRegistration;
import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.models.spi.ClassDetailsRegistry;

View File

@ -0,0 +1,229 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models;
import java.util.function.Consumer;
import org.hibernate.annotations.DialectOverride;
import org.hibernate.annotations.FetchProfileOverride;
import org.hibernate.annotations.FetchProfileOverrides;
import org.hibernate.boot.models.annotations.internal.FetchProfileOverrideAnnotation;
import org.hibernate.boot.models.annotations.internal.FetchProfileOverridesAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenCheckAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenChecksAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenColumnDefaultAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenColumnDefaultsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenDiscriminatorFormulaAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenDiscriminatorFormulasAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenFilterDefOverridesAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenFilterDefsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenFilterOverridesAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenFiltersAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenFormulaAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenFormulasAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenGeneratedColumnAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenGeneratedColumnsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenJoinFormulaAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenJoinFormulasAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenOrderByAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenOrderBysAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeleteAllAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeleteAllsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeleteAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLDeletesAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLInsertAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLInsertsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLOrderAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLOrdersAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLRestrictionAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLRestrictionsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLSelectAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLSelectsAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLUpdateAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenSQLUpdatesAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenWhereAnnotation;
import org.hibernate.boot.models.annotations.internal.OverriddenWheresAnnotation;
import org.hibernate.boot.models.annotations.internal.OverrideVersionAnnotation;
import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.models.internal.OrmAnnotationDescriptor;
import org.hibernate.models.spi.AnnotationDescriptor;
/**
* @author Steve Ebersole
*/
public interface DialectOverrideAnnotations {
OrmAnnotationDescriptor<DialectOverride.Checks, OverriddenChecksAnnotation> DIALECT_OVERRIDE_CHECKS = new OrmAnnotationDescriptor<>(
DialectOverride.Checks.class,
OverriddenChecksAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.Check, OverriddenCheckAnnotation> DIALECT_OVERRIDE_CHECK = new OrmAnnotationDescriptor<>(
DialectOverride.Check.class,
OverriddenCheckAnnotation.class,
DIALECT_OVERRIDE_CHECKS
);
OrmAnnotationDescriptor<DialectOverride.OrderBys, OverriddenOrderBysAnnotation> DIALECT_OVERRIDE_ORDER_BYS = new OrmAnnotationDescriptor<>(
DialectOverride.OrderBys.class,
OverriddenOrderBysAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.OrderBy, OverriddenOrderByAnnotation> DIALECT_OVERRIDE_ORDER_BY = new OrmAnnotationDescriptor<>(
DialectOverride.OrderBy.class,
OverriddenOrderByAnnotation.class,
DIALECT_OVERRIDE_ORDER_BYS
);
OrmAnnotationDescriptor<DialectOverride.ColumnDefaults, OverriddenColumnDefaultsAnnotation> DIALECT_OVERRIDE_COLUMN_DEFAULTS = new OrmAnnotationDescriptor<>(
DialectOverride.ColumnDefaults.class,
OverriddenColumnDefaultsAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.ColumnDefault, OverriddenColumnDefaultAnnotation> DIALECT_OVERRIDE_COLUMN_DEFAULT = new OrmAnnotationDescriptor<>(
DialectOverride.ColumnDefault.class,
OverriddenColumnDefaultAnnotation.class,
DIALECT_OVERRIDE_COLUMN_DEFAULTS
);
OrmAnnotationDescriptor<DialectOverride.GeneratedColumns, OverriddenGeneratedColumnsAnnotation> DIALECT_OVERRIDE_GENERATED_COLUMNS = new OrmAnnotationDescriptor<>(
DialectOverride.GeneratedColumns.class,
OverriddenGeneratedColumnsAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.GeneratedColumn, OverriddenGeneratedColumnAnnotation> DIALECT_OVERRIDE_GENERATED_COLUMN = new OrmAnnotationDescriptor<>(
DialectOverride.GeneratedColumn.class,
OverriddenGeneratedColumnAnnotation.class,
DIALECT_OVERRIDE_GENERATED_COLUMNS
);
OrmAnnotationDescriptor<DialectOverride.DiscriminatorFormulas, OverriddenDiscriminatorFormulasAnnotation> DIALECT_OVERRIDE_DISCRIMINATOR_FORMULAS = new OrmAnnotationDescriptor<>(
DialectOverride.DiscriminatorFormulas.class,
OverriddenDiscriminatorFormulasAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.DiscriminatorFormula, OverriddenDiscriminatorFormulaAnnotation> DIALECT_OVERRIDE_DISCRIMINATOR_FORMULA = new OrmAnnotationDescriptor<>(
DialectOverride.DiscriminatorFormula.class,
OverriddenDiscriminatorFormulaAnnotation.class,
DIALECT_OVERRIDE_DISCRIMINATOR_FORMULAS
);
OrmAnnotationDescriptor<FetchProfileOverrides, FetchProfileOverridesAnnotation> FETCH_PROFILE_OVERRIDES = new OrmAnnotationDescriptor<>(
FetchProfileOverrides.class,
FetchProfileOverridesAnnotation.class
);
OrmAnnotationDescriptor<FetchProfileOverride, FetchProfileOverrideAnnotation> FETCH_PROFILE_OVERRIDE = new OrmAnnotationDescriptor<>(
FetchProfileOverride.class,
FetchProfileOverrideAnnotation.class,
FETCH_PROFILE_OVERRIDES
);
OrmAnnotationDescriptor<DialectOverride.FilterOverrides, OverriddenFilterOverridesAnnotation> DIALECT_OVERRIDE_FILTER_OVERRIDES = new OrmAnnotationDescriptor<>(
DialectOverride.FilterOverrides.class,
OverriddenFilterOverridesAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.Filters, OverriddenFiltersAnnotation> DIALECT_OVERRIDE_FILTERS = new OrmAnnotationDescriptor<DialectOverride.Filters, OverriddenFiltersAnnotation>(
DialectOverride.Filters.class,
OverriddenFiltersAnnotation.class,
DIALECT_OVERRIDE_FILTER_OVERRIDES
);
OrmAnnotationDescriptor<DialectOverride.FilterDefOverrides, OverriddenFilterDefOverridesAnnotation> DIALECT_OVERRIDE_FILTER_DEF_OVERRIDES = new OrmAnnotationDescriptor<>(
DialectOverride.FilterDefOverrides.class,
OverriddenFilterDefOverridesAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.FilterDefs, OverriddenFilterDefsAnnotation> DIALECT_OVERRIDE_FILTER_DEFS = new OrmAnnotationDescriptor<>(
DialectOverride.FilterDefs.class,
OverriddenFilterDefsAnnotation.class,
DIALECT_OVERRIDE_FILTER_DEF_OVERRIDES
);
OrmAnnotationDescriptor<DialectOverride.Formulas, OverriddenFormulasAnnotation> DIALECT_OVERRIDE_FORMULAS = new OrmAnnotationDescriptor<>(
DialectOverride.Formulas.class,
OverriddenFormulasAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.Formula, OverriddenFormulaAnnotation> DIALECT_OVERRIDE_FORMULA = new OrmAnnotationDescriptor<>(
DialectOverride.Formula.class,
OverriddenFormulaAnnotation.class,
DIALECT_OVERRIDE_FORMULAS
);
OrmAnnotationDescriptor<DialectOverride.JoinFormulas, OverriddenJoinFormulasAnnotation> DIALECT_OVERRIDE_JOIN_FORMULAS = new OrmAnnotationDescriptor<>(
DialectOverride.JoinFormulas.class,
OverriddenJoinFormulasAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.JoinFormula, OverriddenJoinFormulaAnnotation> DIALECT_OVERRIDE_JOIN_FORMULA = new OrmAnnotationDescriptor<>(
DialectOverride.JoinFormula.class,
OverriddenJoinFormulaAnnotation.class,
DIALECT_OVERRIDE_JOIN_FORMULAS
);
OrmAnnotationDescriptor<DialectOverride.Wheres, OverriddenWheresAnnotation> DIALECT_OVERRIDE_WHERES = new OrmAnnotationDescriptor<>(
DialectOverride.Wheres.class,
OverriddenWheresAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.Where, OverriddenWhereAnnotation> DIALECT_OVERRIDE_WHERE = new OrmAnnotationDescriptor<>(
DialectOverride.Where.class,
OverriddenWhereAnnotation.class,
DIALECT_OVERRIDE_WHERES
);
OrmAnnotationDescriptor<DialectOverride.SQLInserts, OverriddenSQLInsertsAnnotation> DIALECT_OVERRIDE_SQL_INSERTS = new OrmAnnotationDescriptor<>(
DialectOverride.SQLInserts.class,
OverriddenSQLInsertsAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLInsert, OverriddenSQLInsertAnnotation> DIALECT_OVERRIDE_SQL_INSERT = new OrmAnnotationDescriptor<>(
DialectOverride.SQLInsert.class,
OverriddenSQLInsertAnnotation.class,
DIALECT_OVERRIDE_SQL_INSERTS
);
OrmAnnotationDescriptor<DialectOverride.SQLUpdates, OverriddenSQLUpdatesAnnotation> DIALECT_OVERRIDE_SQL_UPDATES = new OrmAnnotationDescriptor<>(
DialectOverride.SQLUpdates.class,
OverriddenSQLUpdatesAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLUpdate, OverriddenSQLUpdateAnnotation> DIALECT_OVERRIDE_SQL_UPDATE = new OrmAnnotationDescriptor<>(
DialectOverride.SQLUpdate.class,
OverriddenSQLUpdateAnnotation.class,
DIALECT_OVERRIDE_SQL_UPDATES
);
OrmAnnotationDescriptor<DialectOverride.SQLDeletes, OverriddenSQLDeletesAnnotation> DIALECT_OVERRIDE_SQL_DELETES = new OrmAnnotationDescriptor<>(
DialectOverride.SQLDeletes.class,
OverriddenSQLDeletesAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLDelete, OverriddenSQLDeleteAnnotation> DIALECT_OVERRIDE_SQL_DELETE = new OrmAnnotationDescriptor<>(
DialectOverride.SQLDelete.class,
OverriddenSQLDeleteAnnotation.class,
DIALECT_OVERRIDE_SQL_DELETES
);
OrmAnnotationDescriptor<DialectOverride.SQLDeleteAlls, OverriddenSQLDeleteAllsAnnotation> DIALECT_OVERRIDE_SQL_DELETE_ALLS = new OrmAnnotationDescriptor<>(
DialectOverride.SQLDeleteAlls.class,
OverriddenSQLDeleteAllsAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLDeleteAll, OverriddenSQLDeleteAllAnnotation> DIALECT_OVERRIDE_SQL_DELETE_ALL = new OrmAnnotationDescriptor<>(
DialectOverride.SQLDeleteAll.class,
OverriddenSQLDeleteAllAnnotation.class,
DIALECT_OVERRIDE_SQL_DELETE_ALLS
);
OrmAnnotationDescriptor<DialectOverride.SQLOrders, OverriddenSQLOrdersAnnotation> DIALECT_OVERRIDE_SQL_ORDERS = new OrmAnnotationDescriptor<>(
DialectOverride.SQLOrders.class,
OverriddenSQLOrdersAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLOrder, OverriddenSQLOrderAnnotation> DIALECT_OVERRIDE_SQL_ORDER = new OrmAnnotationDescriptor<>(
DialectOverride.SQLOrder.class,
OverriddenSQLOrderAnnotation.class,
DIALECT_OVERRIDE_SQL_ORDERS
);
OrmAnnotationDescriptor<DialectOverride.SQLRestrictions, OverriddenSQLRestrictionsAnnotation> DIALECT_OVERRIDE_SQL_RESTRICTIONS = new OrmAnnotationDescriptor<>(
DialectOverride.SQLRestrictions.class,
OverriddenSQLRestrictionsAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLRestriction, OverriddenSQLRestrictionAnnotation> DIALECT_OVERRIDE_SQL_RESTRICTION = new OrmAnnotationDescriptor<>(
DialectOverride.SQLRestriction.class,
OverriddenSQLRestrictionAnnotation.class,
DIALECT_OVERRIDE_SQL_RESTRICTIONS
);
OrmAnnotationDescriptor<DialectOverride.SQLSelects, OverriddenSQLSelectsAnnotation> DIALECT_OVERRIDE_SQL_SELECTS = new OrmAnnotationDescriptor<>(
DialectOverride.SQLSelects.class,
OverriddenSQLSelectsAnnotation.class
);
OrmAnnotationDescriptor<DialectOverride.SQLSelect, OverriddenSQLSelectAnnotation> DIALECT_OVERRIDE_SQL_SELECT = new OrmAnnotationDescriptor<>(
DialectOverride.SQLSelect.class,
OverriddenSQLSelectAnnotation.class,
DIALECT_OVERRIDE_SQL_SELECTS
);
OrmAnnotationDescriptor<DialectOverride.Version, OverrideVersionAnnotation> DIALECT_OVERRIDE_VERSION = new OrmAnnotationDescriptor<>(
DialectOverride.Version.class,
OverrideVersionAnnotation.class
);
static void forEachAnnotation(Consumer<AnnotationDescriptor<?>> consumer) {
OrmAnnotationHelper.forEachOrmAnnotation( DialectOverrideAnnotations.class, consumer );
}
}

View File

@ -10,16 +10,12 @@ import java.lang.annotation.Annotation;
import java.util.function.Consumer;
import org.hibernate.annotations.*;
import org.hibernate.boot.internal.Abstract;
import org.hibernate.boot.internal.AnyKeyType;
import org.hibernate.boot.internal.CollectionClassification;
import org.hibernate.boot.internal.Extends;
import org.hibernate.boot.internal.Target;
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper;
import org.hibernate.boot.models.annotations.internal.*;
import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.models.internal.OrmAnnotationDescriptor;
import org.hibernate.models.spi.AnnotationDescriptor;
import static org.hibernate.models.internal.AnnotationHelper.createOrmDescriptor;
/**
* Details about Hibernate annotations.
*
@ -33,186 +29,657 @@ import static org.hibernate.models.internal.AnnotationHelper.createOrmDescriptor
*/
@SuppressWarnings({ "deprecation", "removal", "unused" })
public interface HibernateAnnotations {
AnnotationDescriptor<Any> ANY = createOrmDescriptor( Any.class );
AnnotationDescriptor<AnyDiscriminator> ANY_DISCRIMINATOR = createOrmDescriptor( AnyDiscriminator.class );
AnnotationDescriptor<AnyDiscriminatorValues> ANY_DISCRIMINATOR_VALUES = createOrmDescriptor( AnyDiscriminatorValues.class );
AnnotationDescriptor<AnyDiscriminatorValue> ANY_DISCRIMINATOR_VALUE = createOrmDescriptor( AnyDiscriminatorValue.class, ANY_DISCRIMINATOR_VALUES );
AnnotationDescriptor<AnyKeyJavaClass> ANY_KEY_JAVA_CLASS = createOrmDescriptor( AnyKeyJavaClass.class );
AnnotationDescriptor<AnyKeyJavaType> ANY_KEY_JAVA_TYPE = createOrmDescriptor( AnyKeyJavaType.class );
AnnotationDescriptor<AnyKeyJdbcType> ANY_KEY_JDBC_TYPE = createOrmDescriptor( AnyKeyJdbcType.class );
AnnotationDescriptor<AnyKeyJdbcTypeCode> ANY_KEY_JDBC_TYPE_CODE = createOrmDescriptor( AnyKeyJdbcTypeCode.class );
AnnotationDescriptor<AttributeAccessor> ATTRIBUTE_ACCESSOR = createOrmDescriptor( AttributeAccessor.class );
AnnotationDescriptor<AttributeBinderType> ATTRIBUTE_BINDER_TYPE = createOrmDescriptor( AttributeBinderType.class );
AnnotationDescriptor<Bag> BAG = createOrmDescriptor( Bag.class );
AnnotationDescriptor<BatchSize> BATCH_SIZE = createOrmDescriptor( BatchSize.class );
AnnotationDescriptor<Cache> CACHE = createOrmDescriptor( Cache.class );
AnnotationDescriptor<Cascade> CASCADE = createOrmDescriptor( Cascade.class );
AnnotationDescriptor<Checks> CHECKS = createOrmDescriptor( Checks.class );
AnnotationDescriptor<Check> CHECK = createOrmDescriptor( Check.class, CHECKS );
AnnotationDescriptor<CollectionId> COLLECTION_ID = createOrmDescriptor( CollectionId.class );
AnnotationDescriptor<CollectionIdJavaType> COLLECTION_ID_JAVA_TYPE = createOrmDescriptor( CollectionIdJavaType.class );
AnnotationDescriptor<CollectionIdJdbcType> COLLECTION_ID_JDBC_TYPE = createOrmDescriptor( CollectionIdJdbcType.class );
AnnotationDescriptor<CollectionIdJdbcTypeCode> COLLECTION_ID_JDBC_TYPE_CODE = createOrmDescriptor( CollectionIdJdbcTypeCode.class );
AnnotationDescriptor<CollectionIdMutability> COLLECTION_ID_MUTABILITY = createOrmDescriptor( CollectionIdMutability.class );
AnnotationDescriptor<CollectionIdType> COLLECTION_ID_TYPE = createOrmDescriptor( CollectionIdType.class );
AnnotationDescriptor<CollectionType> COLLECTION_TYPE = createOrmDescriptor( CollectionType.class );
AnnotationDescriptor<CollectionTypeRegistrations> COLLECTION_TYPE_REGS = createOrmDescriptor( CollectionTypeRegistrations.class );
AnnotationDescriptor<CollectionTypeRegistration> COLLECTION_TYPE_REG = createOrmDescriptor( CollectionTypeRegistration.class, COLLECTION_TYPE_REGS );
AnnotationDescriptor<ColumnDefault> COLUMN_DEFAULT = createOrmDescriptor( ColumnDefault.class );
AnnotationDescriptor<ColumnTransformers> COLUMN_TRANSFORMERS = createOrmDescriptor( ColumnTransformers.class );
AnnotationDescriptor<ColumnTransformer> COLUMN_TRANSFORMER = createOrmDescriptor( ColumnTransformer.class, COLUMN_TRANSFORMERS );
AnnotationDescriptor<Comment> COMMENT = createOrmDescriptor( Comment.class );
AnnotationDescriptor<CompositeType> COMPOSITE_TYPE = createOrmDescriptor( CompositeType.class );
AnnotationDescriptor<CompositeTypeRegistrations> COMPOSITE_TYPE_REGS = createOrmDescriptor( CompositeTypeRegistrations.class );
AnnotationDescriptor<CompositeTypeRegistration> COMPOSITE_TYPE_REG = createOrmDescriptor( CompositeTypeRegistration.class, COMPOSITE_TYPE_REGS );
AnnotationDescriptor<ConverterRegistrations> CONVERTER_REGS = createOrmDescriptor( ConverterRegistrations.class );
AnnotationDescriptor<ConverterRegistration> CONVERTER_REG = createOrmDescriptor( ConverterRegistration.class, CONVERTER_REGS );
AnnotationDescriptor<CreationTimestamp> CREATION_TIMESTAMP = createOrmDescriptor( CreationTimestamp.class );
AnnotationDescriptor<CurrentTimestamp> CURRENT_TIMESTAMP = createOrmDescriptor( CurrentTimestamp.class );
AnnotationDescriptor<DiscriminatorFormula> DISCRIMINATOR_FORMULA = createOrmDescriptor( DiscriminatorFormula.class );
AnnotationDescriptor<DiscriminatorOptions> DISCRIMINATOR_OPTIONS = createOrmDescriptor( DiscriminatorOptions.class );
AnnotationDescriptor<DynamicInsert> DYNAMIC_INSERT = createOrmDescriptor( DynamicInsert.class );
AnnotationDescriptor<DynamicUpdate> DYNAMIC_UPDATE = createOrmDescriptor( DynamicUpdate.class );
AnnotationDescriptor<EmbeddableInstantiator> EMBEDDABLE_INSTANTIATOR = createOrmDescriptor( EmbeddableInstantiator.class );
AnnotationDescriptor<EmbeddableInstantiatorRegistrations> EMBEDDABLE_INSTANTIATOR_REGS = createOrmDescriptor( EmbeddableInstantiatorRegistrations.class );
AnnotationDescriptor<EmbeddableInstantiatorRegistration> EMBEDDABLE_INSTANTIATOR_REG = createOrmDescriptor( EmbeddableInstantiatorRegistration.class, EMBEDDABLE_INSTANTIATOR_REGS );
AnnotationDescriptor<Fetch> FETCH = createOrmDescriptor( Fetch.class );
AnnotationDescriptor<FetchProfiles> FETCH_PROFILES = createOrmDescriptor( FetchProfiles.class );
AnnotationDescriptor<FetchProfile> FETCH_PROFILE = createOrmDescriptor( FetchProfile.class, FETCH_PROFILES );
AnnotationDescriptor<Filters> FILTERS = createOrmDescriptor( Filters.class );
AnnotationDescriptor<Filter> FILTER = createOrmDescriptor( Filter.class, FILTERS );
AnnotationDescriptor<FilterDefs> FILTER_DEFS = createOrmDescriptor( FilterDefs.class );
AnnotationDescriptor<FilterDef> FILTER_DEF = createOrmDescriptor( FilterDef.class, FILTER_DEFS );
AnnotationDescriptor<FilterJoinTables> FILTER_JOIN_TABLES = createOrmDescriptor( FilterJoinTables.class );
AnnotationDescriptor<FilterJoinTable> FILTER_JOIN_TABLE = createOrmDescriptor( FilterJoinTable.class, FILTER_JOIN_TABLES );
AnnotationDescriptor<ForeignKey> FOREIGN_KEY = createOrmDescriptor( ForeignKey.class );
AnnotationDescriptor<Formula> FORMULA = createOrmDescriptor( Formula.class );
AnnotationDescriptor<Generated> GENERATED = createOrmDescriptor( Generated.class );
AnnotationDescriptor<GeneratedColumn> GENERATED_COLUMN = createOrmDescriptor( GeneratedColumn.class );
AnnotationDescriptor<GeneratorType> GENERATOR_TYPE = createOrmDescriptor( GeneratorType.class );
AnnotationDescriptor<GenericGenerators> GENERIC_GENERATORS = createOrmDescriptor( GenericGenerators.class );
AnnotationDescriptor<GenericGenerator> GENERIC_GENERATOR = createOrmDescriptor( GenericGenerator.class, GENERIC_GENERATORS );
AnnotationDescriptor<IdGeneratorType> ID_GENERATOR_TYPE = createOrmDescriptor( IdGeneratorType.class );
AnnotationDescriptor<Immutable> IMMUTABLE = createOrmDescriptor( Immutable.class );
AnnotationDescriptor<Imported> IMPORTED = createOrmDescriptor( Imported.class );
AnnotationDescriptor<Index> INDEX = createOrmDescriptor( Index.class );
AnnotationDescriptor<IndexColumn> INDEX_COLUMN = createOrmDescriptor( IndexColumn.class );
AnnotationDescriptor<Instantiator> INSTANTIATOR = createOrmDescriptor( Instantiator.class );
AnnotationDescriptor<JavaType> JAVA_TYPE = createOrmDescriptor( JavaType.class );
AnnotationDescriptor<JavaTypeRegistrations> JAVA_TYPE_REGS = createOrmDescriptor( JavaTypeRegistrations.class );
AnnotationDescriptor<JavaTypeRegistration> JAVA_TYPE_REG = createOrmDescriptor( JavaTypeRegistration.class, JAVA_TYPE_REGS );
AnnotationDescriptor<JdbcType> JDBC_TYPE = createOrmDescriptor( JdbcType.class );
AnnotationDescriptor<JdbcTypeCode> JDBC_TYPE_CODE = createOrmDescriptor( JdbcTypeCode.class );
AnnotationDescriptor<JdbcTypeRegistrations> JDBC_TYPE_REGS = createOrmDescriptor( JdbcTypeRegistrations.class );
AnnotationDescriptor<JdbcTypeRegistration> JDBC_TYPE_REG = createOrmDescriptor( JdbcTypeRegistration.class, JDBC_TYPE_REGS );
AnnotationDescriptor<JoinColumnsOrFormulas> JOIN_COLUMNS_OR_FORMULAS = createOrmDescriptor( JoinColumnsOrFormulas.class );
AnnotationDescriptor<JoinColumnOrFormula> JOIN_COLUMN_OR_FORMULA = createOrmDescriptor( JoinColumnOrFormula.class, JOIN_COLUMNS_OR_FORMULAS );
AnnotationDescriptor<JoinFormula> JOIN_FORMULA = createOrmDescriptor( JoinFormula.class );
AnnotationDescriptor<LazyCollection> LAZY_COLLECTION = createOrmDescriptor( LazyCollection.class );
AnnotationDescriptor<LazyGroup> LAZY_GROUP = createOrmDescriptor( LazyGroup.class );
AnnotationDescriptor<LazyToOne> LAZY_TO_ONE = createOrmDescriptor( LazyToOne.class );
AnnotationDescriptor<ListIndexBase> LIST_INDEX_BASE = createOrmDescriptor( ListIndexBase.class );
AnnotationDescriptor<ListIndexJavaType> LIST_INDEX_JAVA_TYPE = createOrmDescriptor( ListIndexJavaType.class );
AnnotationDescriptor<ListIndexJdbcType> LIST_INDEX_JDBC_TYPE = createOrmDescriptor( ListIndexJdbcType.class );
AnnotationDescriptor<ListIndexJdbcTypeCode> LIST_INDEX_JDBC_TYPE_CODE = createOrmDescriptor( ListIndexJdbcTypeCode.class );
AnnotationDescriptor<Loader> LOADER = createOrmDescriptor( Loader.class );
AnnotationDescriptor<ManyToAny> MANY_TO_ANY = createOrmDescriptor( ManyToAny.class );
AnnotationDescriptor<MapKeyCompositeType> MAP_KEY_COMPOSITE_TYPE = createOrmDescriptor( MapKeyCompositeType.class );
AnnotationDescriptor<MapKeyJavaType> MAP_KEY_JAVA_TYPE = createOrmDescriptor( MapKeyJavaType.class );
AnnotationDescriptor<MapKeyJdbcType> MAP_KEY_JDBC_TYPE = createOrmDescriptor( MapKeyJdbcType.class );
AnnotationDescriptor<MapKeyJdbcTypeCode> MAP_KEY_JDBC_TYPE_CODE = createOrmDescriptor( MapKeyJdbcTypeCode.class );
AnnotationDescriptor<MapKeyMutability> MAP_KEY_MUTABILITY = createOrmDescriptor( MapKeyMutability.class );
AnnotationDescriptor<MapKeyType> MAP_KEY_TYPE = createOrmDescriptor( MapKeyType.class );
AnnotationDescriptor<Mutability> MUTABILITY = createOrmDescriptor( Mutability.class );
AnnotationDescriptor<NamedNativeQueries> NAMED_NATIVE_QUERIES = createOrmDescriptor( NamedNativeQueries.class );
AnnotationDescriptor<NamedNativeQuery> NAMED_NATIVE_QUERY = createOrmDescriptor( NamedNativeQuery.class, NAMED_NATIVE_QUERIES );
AnnotationDescriptor<NamedQueries> NAMED_QUERIES = createOrmDescriptor( NamedQueries.class );
AnnotationDescriptor<NamedQuery> NAMED_QUERY = createOrmDescriptor( NamedQuery.class, NAMED_QUERIES );
AnnotationDescriptor<Nationalized> NATIONALIZED = createOrmDescriptor( Nationalized.class );
AnnotationDescriptor<NaturalId> NATURAL_ID = createOrmDescriptor( NaturalId.class );
AnnotationDescriptor<NaturalIdCache> NATURAL_ID_CACHE = createOrmDescriptor( NaturalIdCache.class );
AnnotationDescriptor<NotFound> NOT_FOUND = createOrmDescriptor( NotFound.class );
AnnotationDescriptor<OnDelete> ON_DELETE = createOrmDescriptor( OnDelete.class );
AnnotationDescriptor<OptimisticLock> OPTIMISTIC_LOCK = createOrmDescriptor( OptimisticLock.class );
AnnotationDescriptor<OptimisticLocking> OPTIMISTIC_LOCKING = createOrmDescriptor( OptimisticLocking.class );
AnnotationDescriptor<OrderBy> ORDER_BY = createOrmDescriptor( OrderBy.class );
AnnotationDescriptor<ParamDef> PARAM_DEF = createOrmDescriptor( ParamDef.class );
AnnotationDescriptor<Parameter> PARAMETER = createOrmDescriptor( Parameter.class );
AnnotationDescriptor<Parent> PARENT = createOrmDescriptor( Parent.class );
AnnotationDescriptor<PartitionKey> PARTITION_KEY = createOrmDescriptor( PartitionKey.class );
AnnotationDescriptor<Polymorphism> POLYMORPHISM = createOrmDescriptor( Polymorphism.class );
AnnotationDescriptor<Proxy> PROXY = createOrmDescriptor( Proxy.class );
AnnotationDescriptor<RowId> ROW_ID = createOrmDescriptor( RowId.class );
AnnotationDescriptor<SecondaryRows> SECONDARY_ROWS = createOrmDescriptor( SecondaryRows.class );
AnnotationDescriptor<SecondaryRow> SECONDARY_ROW = createOrmDescriptor( SecondaryRow.class, SECONDARY_ROWS );
AnnotationDescriptor<SelectBeforeUpdate> SELECT_BEFORE_UPDATE = createOrmDescriptor( SelectBeforeUpdate.class );
AnnotationDescriptor<SortComparator> SORT_COMPARATOR = createOrmDescriptor( SortComparator.class );
AnnotationDescriptor<SortNatural> SORT_NATURAL = createOrmDescriptor( SortNatural.class );
AnnotationDescriptor<Source> SOURCE = createOrmDescriptor( Source.class );
AnnotationDescriptor<SQLDeletes> SQL_DELETES = createOrmDescriptor( SQLDeletes.class );
AnnotationDescriptor<SQLDelete> SQL_DELETE = createOrmDescriptor( SQLDelete.class, SQL_DELETES );
AnnotationDescriptor<SQLDeleteAll> SQL_DELETE_ALL = createOrmDescriptor( SQLDeleteAll.class );
AnnotationDescriptor<SqlFragmentAlias> SQL_FRAGMENT_ALIAS = createOrmDescriptor( SqlFragmentAlias.class );
AnnotationDescriptor<SQLInserts> SQL_INSERTS = createOrmDescriptor( SQLInserts.class );
AnnotationDescriptor<SQLInsert> SQL_INSERT = createOrmDescriptor( SQLInsert.class, SQL_INSERTS );
AnnotationDescriptor<SQLRestriction> SQL_RESTRICTION = createOrmDescriptor( SQLRestriction.class, SQL_INSERTS );
AnnotationDescriptor<SQLJoinTableRestriction> SQL_RESTRICTION_JOIN_TABLE = createOrmDescriptor( SQLJoinTableRestriction.class, SQL_INSERTS );
AnnotationDescriptor<SQLUpdates> SQL_UPDATES = createOrmDescriptor( SQLUpdates.class );
AnnotationDescriptor<SQLUpdate> SQL_UPDATE = createOrmDescriptor( SQLUpdate.class, SQL_UPDATES );
AnnotationDescriptor<Struct> STRUCT = createOrmDescriptor( Struct.class );
AnnotationDescriptor<Subselect> SUBSELECT = createOrmDescriptor( Subselect.class );
AnnotationDescriptor<Synchronize> SYNCHRONIZE = createOrmDescriptor( Synchronize.class );
AnnotationDescriptor<Tables> TABLES = createOrmDescriptor( Tables.class );
AnnotationDescriptor<Table> TABLE = createOrmDescriptor( Table.class, TABLES );
AnnotationDescriptor<TenantId> TENANT_ID = createOrmDescriptor( TenantId.class );
AnnotationDescriptor<TimeZoneColumn> TZ_COLUMN = createOrmDescriptor( TimeZoneColumn.class );
AnnotationDescriptor<TimeZoneStorage> TZ_STORAGE = createOrmDescriptor( TimeZoneStorage.class );
AnnotationDescriptor<Type> TYPE = createOrmDescriptor( Type.class );
AnnotationDescriptor<TypeBinderType> TYPE_BINDER_TYPE = createOrmDescriptor( TypeBinderType.class );
AnnotationDescriptor<TypeRegistrations> TYPE_REGS = createOrmDescriptor( TypeRegistrations.class );
AnnotationDescriptor<TypeRegistration> TYPE_REG = createOrmDescriptor( TypeRegistration.class, TYPE_REGS );
AnnotationDescriptor<UpdateTimestamp> UPDATE_TIMESTAMP = createOrmDescriptor( UpdateTimestamp.class );
AnnotationDescriptor<UuidGenerator> UUID_GENERATOR = createOrmDescriptor( UuidGenerator.class );
AnnotationDescriptor<ValueGenerationType> VALUE_GENERATION_TYPE = createOrmDescriptor( ValueGenerationType.class );
AnnotationDescriptor<Where> WHERE = createOrmDescriptor( Where.class );
AnnotationDescriptor<WhereJoinTable> WHERE_JOIN_TABLE = createOrmDescriptor( WhereJoinTable.class );
AnnotationDescriptor<Abstract> ABSTRACT = createOrmDescriptor( Abstract.class );
AnnotationDescriptor<AnyKeyType> ANY_KEY_TYPE = createOrmDescriptor( AnyKeyType.class );
AnnotationDescriptor<CollectionClassification> COLLECTION_CLASSIFICATION = createOrmDescriptor( CollectionClassification.class );
AnnotationDescriptor<Extends> EXTENDS = createOrmDescriptor( Extends.class );
AnnotationDescriptor<Target> TARGET = createOrmDescriptor( Target.class );
AnnotationDescriptor<DialectOverride.Checks> DIALECT_OVERRIDE_CHECKS = createOrmDescriptor( DialectOverride.Checks.class );
AnnotationDescriptor<DialectOverride.Check> DIALECT_OVERRIDE_CHECK = createOrmDescriptor( DialectOverride.Check.class, DIALECT_OVERRIDE_CHECKS );
AnnotationDescriptor<DialectOverride.OrderBys> DIALECT_OVERRIDE_ORDER_BYS = createOrmDescriptor( DialectOverride.OrderBys.class );
AnnotationDescriptor<DialectOverride.OrderBy> DIALECT_OVERRIDE_ORDER_BY = createOrmDescriptor( DialectOverride.OrderBy.class, DIALECT_OVERRIDE_ORDER_BYS );
AnnotationDescriptor<DialectOverride.ColumnDefaults> DIALECT_OVERRIDE_COLUMN_DEFAULTS = createOrmDescriptor( DialectOverride.ColumnDefaults.class );
AnnotationDescriptor<DialectOverride.ColumnDefault> DIALECT_OVERRIDE_COLUMN_DEFAULT = createOrmDescriptor( DialectOverride.ColumnDefault.class, DIALECT_OVERRIDE_COLUMN_DEFAULTS );
AnnotationDescriptor<DialectOverride.GeneratedColumns> DIALECT_OVERRIDE_GENERATED_COLUMNS = createOrmDescriptor( DialectOverride.GeneratedColumns.class );
AnnotationDescriptor<DialectOverride.GeneratedColumn> DIALECT_OVERRIDE_GENERATED_COLUMN = createOrmDescriptor( DialectOverride.GeneratedColumn.class, DIALECT_OVERRIDE_GENERATED_COLUMNS );
AnnotationDescriptor<DialectOverride.DiscriminatorFormulas> DIALECT_OVERRIDE_DISCRIMINATOR_FORMULAS = createOrmDescriptor( DialectOverride.DiscriminatorFormulas.class );
AnnotationDescriptor<DialectOverride.DiscriminatorFormula> DIALECT_OVERRIDE_DISCRIMINATOR_FORMULA = createOrmDescriptor( DialectOverride.DiscriminatorFormula.class, DIALECT_OVERRIDE_DISCRIMINATOR_FORMULAS );
AnnotationDescriptor<DialectOverride.Formulas> DIALECT_OVERRIDE_FORMULAS = createOrmDescriptor( DialectOverride.Formulas.class );
AnnotationDescriptor<DialectOverride.Formula> DIALECT_OVERRIDE_FORMULA = createOrmDescriptor( DialectOverride.Formula.class, DIALECT_OVERRIDE_FORMULAS );
AnnotationDescriptor<DialectOverride.JoinFormulas> DIALECT_OVERRIDE_JOIN_FORMULAS = createOrmDescriptor( DialectOverride.JoinFormulas.class );
AnnotationDescriptor<DialectOverride.JoinFormula> DIALECT_OVERRIDE_JOIN_FORMULA = createOrmDescriptor( DialectOverride.JoinFormula.class, DIALECT_OVERRIDE_JOIN_FORMULAS );
AnnotationDescriptor<DialectOverride.Wheres> DIALECT_OVERRIDE_WHERES = createOrmDescriptor( DialectOverride.Wheres.class );
AnnotationDescriptor<DialectOverride.Where> DIALECT_OVERRIDE_WHERE = createOrmDescriptor( DialectOverride.Where.class, DIALECT_OVERRIDE_WHERES );
AnnotationDescriptor<DialectOverride.FilterOverrides> DIALECT_OVERRIDE_FILTER_OVERRIDES = createOrmDescriptor( DialectOverride.FilterOverrides.class );
AnnotationDescriptor<DialectOverride.Filters> DIALECT_OVERRIDE_FILTERS = createOrmDescriptor( DialectOverride.Filters.class, DIALECT_OVERRIDE_FILTER_OVERRIDES );
AnnotationDescriptor<DialectOverride.FilterDefOverrides> DIALECT_OVERRIDE_FILTER_DEF_OVERRIDES = createOrmDescriptor( DialectOverride.FilterDefOverrides.class );
AnnotationDescriptor<DialectOverride.FilterDefs> DIALECT_OVERRIDE_FILTER_DEFS = createOrmDescriptor( DialectOverride.FilterDefs.class, DIALECT_OVERRIDE_FILTER_DEF_OVERRIDES );
AnnotationDescriptor<DialectOverride.Version> DIALECT_OVERRIDE_VERSION = createOrmDescriptor( DialectOverride.Version.class );
AnnotationDescriptor<DialectOverride.SQLInserts> DIALECT_OVERRIDE_SQL_INSERTS = createOrmDescriptor( DialectOverride.SQLInserts.class );
AnnotationDescriptor<DialectOverride.SQLInsert> DIALECT_OVERRIDE_SQL_INSERT = createOrmDescriptor( DialectOverride.SQLInsert.class, DIALECT_OVERRIDE_SQL_INSERTS );
AnnotationDescriptor<DialectOverride.SQLUpdates> DIALECT_OVERRIDE_SQL_UPDATES = createOrmDescriptor( DialectOverride.SQLUpdates.class );
AnnotationDescriptor<DialectOverride.SQLUpdate> DIALECT_OVERRIDE_SQL_UPDATE = createOrmDescriptor( DialectOverride.SQLUpdate.class, DIALECT_OVERRIDE_SQL_UPDATES );
AnnotationDescriptor<DialectOverride.SQLDeletes> DIALECT_OVERRIDE_SQL_DELETES = createOrmDescriptor( DialectOverride.SQLDeletes.class );
AnnotationDescriptor<DialectOverride.SQLDelete> DIALECT_OVERRIDE_SQL_DELETE = createOrmDescriptor( DialectOverride.SQLDelete.class, DIALECT_OVERRIDE_SQL_DELETES );
AnnotationDescriptor<DialectOverride.SQLDeleteAlls> DIALECT_OVERRIDE_SQL_DELETE_ALLS = createOrmDescriptor( DialectOverride.SQLDeleteAlls.class );
AnnotationDescriptor<DialectOverride.SQLDeleteAll> DIALECT_OVERRIDE_SQL_DELETE_ALL = createOrmDescriptor( DialectOverride.SQLDeleteAll.class, DIALECT_OVERRIDE_SQL_DELETE_ALLS );
OrmAnnotationDescriptor<Any,AnyAnnotation> ANY = new OrmAnnotationDescriptor<>(
Any.class,
AnyAnnotation.class
);
OrmAnnotationDescriptor<AnyDiscriminator,AnyDiscriminatorAnnotation> ANY_DISCRIMINATOR = new OrmAnnotationDescriptor<>(
AnyDiscriminator.class,
AnyDiscriminatorAnnotation.class
);
OrmAnnotationDescriptor<AnyDiscriminatorValues,AnyDiscriminatorValuesAnnotation> ANY_DISCRIMINATOR_VALUES = new OrmAnnotationDescriptor<>(
AnyDiscriminatorValues.class,
AnyDiscriminatorValuesAnnotation.class
);
OrmAnnotationDescriptor<AnyDiscriminatorValue,AnyDiscriminatorValueAnnotation> ANY_DISCRIMINATOR_VALUE = new OrmAnnotationDescriptor<>(
AnyDiscriminatorValue.class,
AnyDiscriminatorValueAnnotation.class,
ANY_DISCRIMINATOR_VALUES
);
OrmAnnotationDescriptor<AnyKeyJavaClass,AnyKeyJavaClassAnnotation> ANY_KEY_JAVA_CLASS = new OrmAnnotationDescriptor<>(
AnyKeyJavaClass.class,
AnyKeyJavaClassAnnotation.class
);
OrmAnnotationDescriptor<AnyKeyJavaType,AnyKeyJavaTypeAnnotation> ANY_KEY_JAVA_TYPE = new OrmAnnotationDescriptor<>(
AnyKeyJavaType.class,
AnyKeyJavaTypeAnnotation.class
);
OrmAnnotationDescriptor<AnyKeyJdbcType,AnyKeyJdbcTypeAnnotation> ANY_KEY_JDBC_TYPE = new OrmAnnotationDescriptor<>(
AnyKeyJdbcType.class,
AnyKeyJdbcTypeAnnotation.class
);
OrmAnnotationDescriptor<AnyKeyJdbcTypeCode,AnyKeyJdbcTypeCodeAnnotation> ANY_KEY_JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
AnyKeyJdbcTypeCode.class,
AnyKeyJdbcTypeCodeAnnotation.class
);
OrmAnnotationDescriptor<AnyKeyType, AnyKeTypeAnnotation> ANY_KEY_TYPE = new OrmAnnotationDescriptor<>(
AnyKeyType.class,
AnyKeTypeAnnotation.class
);
OrmAnnotationDescriptor<Array,ArrayAnnotation> ARRAY = new OrmAnnotationDescriptor<>(
Array.class,
ArrayAnnotation.class
);
SpecializedAnnotationDescriptor<AttributeAccessor,AttributeAccessorAnnotation> ATTRIBUTE_ACCESSOR = new SpecializedAnnotationDescriptor<>(
AttributeAccessor.class,
AttributeAccessorAnnotation.class
);
OrmAnnotationDescriptor<AttributeBinderType,AttributeBinderTypeAnnotation> ATTRIBUTE_BINDER_TYPE = new OrmAnnotationDescriptor<>(
AttributeBinderType.class,
AttributeBinderTypeAnnotation.class
);
OrmAnnotationDescriptor<Bag,BagAnnotation> BAG = new OrmAnnotationDescriptor<>(
Bag.class,
BagAnnotation.class
);
SpecializedAnnotationDescriptor<BatchSize,BatchSizeAnnotation> BATCH_SIZE = new SpecializedAnnotationDescriptor<>(
BatchSize.class,
BatchSizeAnnotation.class
);
OrmAnnotationDescriptor<Cache,CacheAnnotation> CACHE = new OrmAnnotationDescriptor<>(
Cache.class,
CacheAnnotation.class
);
OrmAnnotationDescriptor<Cascade,CascadeAnnotation> CASCADE = new OrmAnnotationDescriptor<>(
Cascade.class,
CascadeAnnotation.class
);
OrmAnnotationDescriptor<Checks,ChecksAnnotation> CHECKS = new OrmAnnotationDescriptor<>(
Checks.class,
ChecksAnnotation.class
);
OrmAnnotationDescriptor<Check,CheckAnnotation> CHECK = new OrmAnnotationDescriptor<>(
Check.class,
CheckAnnotation.class,
CHECKS
);
SpecializedAnnotationDescriptor<Collate,CollateAnnotation> COLLATE = new SpecializedAnnotationDescriptor<>(
Collate.class,
CollateAnnotation.class
);
OrmAnnotationDescriptor<CollectionId,CollectionIdAnnotation> COLLECTION_ID = new OrmAnnotationDescriptor<>(
CollectionId.class,
CollectionIdAnnotation.class
);
OrmAnnotationDescriptor<CollectionIdJavaType,CollectionIdJavaTypeAnnotation> COLLECTION_ID_JAVA_TYPE = new OrmAnnotationDescriptor<>(
CollectionIdJavaType.class,
CollectionIdJavaTypeAnnotation.class
);
OrmAnnotationDescriptor<CollectionIdJdbcType,CollectionIdJdbcTypeAnnotation> COLLECTION_ID_JDBC_TYPE = new OrmAnnotationDescriptor<>(
CollectionIdJdbcType.class,
CollectionIdJdbcTypeAnnotation.class
);
OrmAnnotationDescriptor<CollectionIdJdbcTypeCode,CollectionIdJdbcTypeCodeAnnotation> COLLECTION_ID_JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
CollectionIdJdbcTypeCode.class,
CollectionIdJdbcTypeCodeAnnotation.class
);
OrmAnnotationDescriptor<CollectionIdMutability,CollectionIdMutabilityAnnotation> COLLECTION_ID_MUTABILITY = new OrmAnnotationDescriptor<>(
CollectionIdMutability.class,
CollectionIdMutabilityAnnotation.class
);
OrmAnnotationDescriptor<CollectionIdType,CollectionIdTypeAnnotation> COLLECTION_ID_TYPE = new OrmAnnotationDescriptor<>(
CollectionIdType.class,
CollectionIdTypeAnnotation.class
);
OrmAnnotationDescriptor<CollectionType,CollectionTypeAnnotation> COLLECTION_TYPE = new OrmAnnotationDescriptor<>(
CollectionType.class,
CollectionTypeAnnotation.class
);
OrmAnnotationDescriptor<CollectionTypeRegistrations,CollectionTypeRegistrationsAnnotation> COLLECTION_TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
CollectionTypeRegistrations.class,
CollectionTypeRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<CollectionTypeRegistration,CollectionTypeRegistrationAnnotation> COLLECTION_TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
CollectionTypeRegistration.class,
CollectionTypeRegistrationAnnotation.class,
COLLECTION_TYPE_REGISTRATIONS
);
OrmAnnotationDescriptor<ColumnDefault,ColumnDefaultAnnotation> COLUMN_DEFAULT = new OrmAnnotationDescriptor<>(
ColumnDefault.class,
ColumnDefaultAnnotation.class
);
OrmAnnotationDescriptor<Columns,ColumnsAnnotation> COLUMNS = new OrmAnnotationDescriptor<>(
Columns.class,
ColumnsAnnotation.class
);
OrmAnnotationDescriptor<ColumnTransformers,ColumnTransformersAnnotation> COLUMN_TRANSFORMERS = new OrmAnnotationDescriptor<>(
ColumnTransformers.class,
ColumnTransformersAnnotation.class
);
OrmAnnotationDescriptor<ColumnTransformer,ColumnTransformerAnnotation> COLUMN_TRANSFORMER = new OrmAnnotationDescriptor<>(
ColumnTransformer.class,
ColumnTransformerAnnotation.class,
COLUMN_TRANSFORMERS
);
SpecializedAnnotationDescriptor<Comments,CommentsAnnotation> COMMENTS = new SpecializedAnnotationDescriptor<>(
Comments.class,
CommentsAnnotation.class
);
SpecializedAnnotationDescriptor<Comment,CommentAnnotation> COMMENT = new SpecializedAnnotationDescriptor<>(
Comment.class,
CommentAnnotation.class,
COMMENTS
);
OrmAnnotationDescriptor<CompositeType,CompositeTypeAnnotation> COMPOSITE_TYPE = new OrmAnnotationDescriptor<>(
CompositeType.class,
CompositeTypeAnnotation.class
);
OrmAnnotationDescriptor<CompositeTypeRegistrations,CompositeTypeRegistrationsAnnotation> COMPOSITE_TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
CompositeTypeRegistrations.class,
CompositeTypeRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<CompositeTypeRegistration,CompositeTypeRegistrationAnnotation> COMPOSITE_TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
CompositeTypeRegistration.class,
CompositeTypeRegistrationAnnotation.class,
COMPOSITE_TYPE_REGISTRATIONS
);
OrmAnnotationDescriptor<ConcreteProxy,ConcreteProxyAnnotation> CONCRETE_PROXY = new OrmAnnotationDescriptor<>(
ConcreteProxy.class,
ConcreteProxyAnnotation.class
);
OrmAnnotationDescriptor<ConverterRegistrations,ConverterRegistrationsAnnotation> CONVERTER_REGISTRATIONS = new OrmAnnotationDescriptor<>(
ConverterRegistrations.class,
ConverterRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<ConverterRegistration,ConverterRegistrationAnnotation> CONVERTER_REGISTRATION = new OrmAnnotationDescriptor<>(
ConverterRegistration.class,
ConverterRegistrationAnnotation.class,
CONVERTER_REGISTRATIONS
);
OrmAnnotationDescriptor<CreationTimestamp,CreationTimestampAnnotation> CREATION_TIMESTAMP = new OrmAnnotationDescriptor<>(
CreationTimestamp.class,
CreationTimestampAnnotation.class
);
OrmAnnotationDescriptor<CurrentTimestamp,CurrentTimestampAnnotation> CURRENT_TIMESTAMP = new OrmAnnotationDescriptor<>(
CurrentTimestamp.class,
CurrentTimestampAnnotation.class
);
OrmAnnotationDescriptor<DiscriminatorFormula,DiscriminatorFormulaAnnotation> DISCRIMINATOR_FORMULA = new OrmAnnotationDescriptor<>(
DiscriminatorFormula.class,
DiscriminatorFormulaAnnotation.class
);
SpecializedAnnotationDescriptor<DiscriminatorOptions,DiscriminatorOptionsAnnotation> DISCRIMINATOR_OPTIONS = new SpecializedAnnotationDescriptor<>(
DiscriminatorOptions.class,
DiscriminatorOptionsAnnotation.class
);
OrmAnnotationDescriptor<DynamicInsert,DynamicInsertAnnotation> DYNAMIC_INSERT = new OrmAnnotationDescriptor<>(
DynamicInsert.class,
DynamicInsertAnnotation.class
);
OrmAnnotationDescriptor<DynamicUpdate,DynamicUpdateAnnotation> DYNAMIC_UPDATE = new OrmAnnotationDescriptor<>(
DynamicUpdate.class,
DynamicUpdateAnnotation.class
);
OrmAnnotationDescriptor<EmbeddableInstantiator,EmbeddableInstantiatorAnnotation> EMBEDDABLE_INSTANTIATOR = new OrmAnnotationDescriptor<>(
EmbeddableInstantiator.class,
EmbeddableInstantiatorAnnotation.class
);
OrmAnnotationDescriptor<EmbeddableInstantiatorRegistrations,EmbeddableInstantiatorRegistrationsAnnotation> EMBEDDABLE_INSTANTIATOR_REGISTRATIONS = new OrmAnnotationDescriptor<>(
EmbeddableInstantiatorRegistrations.class,
EmbeddableInstantiatorRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<EmbeddableInstantiatorRegistration,EmbeddableInstantiatorRegistrationAnnotation> EMBEDDABLE_INSTANTIATOR_REGISTRATION = new OrmAnnotationDescriptor<>(
EmbeddableInstantiatorRegistration.class,
EmbeddableInstantiatorRegistrationAnnotation.class,
EMBEDDABLE_INSTANTIATOR_REGISTRATIONS
);
OrmAnnotationDescriptor<Fetch,FetchAnnotation> FETCH = new OrmAnnotationDescriptor<>(
Fetch.class,
FetchAnnotation.class
);
OrmAnnotationDescriptor<FetchProfiles,FetchProfilesAnnotation> FETCH_PROFILES = new OrmAnnotationDescriptor<>(
FetchProfiles.class,
FetchProfilesAnnotation.class
);
OrmAnnotationDescriptor<FetchProfile,FetchProfileAnnotation> FETCH_PROFILE = new OrmAnnotationDescriptor<>(
FetchProfile.class,
FetchProfileAnnotation.class,
FETCH_PROFILES
);
OrmAnnotationDescriptor<Filters,FiltersAnnotation> FILTERS = new OrmAnnotationDescriptor<>(
Filters.class,
FiltersAnnotation.class
);
OrmAnnotationDescriptor<Filter,FilterAnnotation> FILTER = new OrmAnnotationDescriptor<>(
Filter.class,
FilterAnnotation.class,
FILTERS
);
OrmAnnotationDescriptor<FilterDefs,FilterDefsAnnotation> FILTER_DEFS = new OrmAnnotationDescriptor<>(
FilterDefs.class,
FilterDefsAnnotation.class
);
OrmAnnotationDescriptor<FilterDef,FilterDefAnnotation> FILTER_DEF = new OrmAnnotationDescriptor<>(
FilterDef.class,
FilterDefAnnotation.class,
FILTER_DEFS
);
OrmAnnotationDescriptor<FilterJoinTables,FilterJoinTablesAnnotation> FILTER_JOIN_TABLES = new OrmAnnotationDescriptor<>(
FilterJoinTables.class,
FilterJoinTablesAnnotation.class
);
OrmAnnotationDescriptor<FilterJoinTable,FilterJoinTableAnnotation> FILTER_JOIN_TABLE = new OrmAnnotationDescriptor<>(
FilterJoinTable.class,
FilterJoinTableAnnotation.class,
FILTER_JOIN_TABLES
);
OrmAnnotationDescriptor<ForeignKey, ForeignKeyAnnotation> FOREIGN_KEY = new OrmAnnotationDescriptor<>(
ForeignKey.class,
ForeignKeyAnnotation.class
);
OrmAnnotationDescriptor<Formula,FormulaAnnotation> FORMULA = new OrmAnnotationDescriptor<>(
Formula.class,
FormulaAnnotation.class
);
OrmAnnotationDescriptor<FractionalSeconds,FractionalSecondsAnnotation> FRACTIONAL_SECONDS = new OrmAnnotationDescriptor<>(
FractionalSeconds.class,
FractionalSecondsAnnotation.class
);
OrmAnnotationDescriptor<Generated,GeneratedAnnotation> GENERATED = new OrmAnnotationDescriptor<>(
Generated.class,
GeneratedAnnotation.class
);
OrmAnnotationDescriptor<GeneratedColumn,GeneratedColumnAnnotation> GENERATED_COLUMN = new OrmAnnotationDescriptor<>(
GeneratedColumn.class,
GeneratedColumnAnnotation.class
);
OrmAnnotationDescriptor<GeneratorType,GeneratorTypeAnnotation> GENERATOR_TYPE = new OrmAnnotationDescriptor<>(
GeneratorType.class,
GeneratorTypeAnnotation.class
);
OrmAnnotationDescriptor<GenericGenerators,GenericGeneratorsAnnotation> GENERIC_GENERATORS = new OrmAnnotationDescriptor<>(
GenericGenerators.class,
GenericGeneratorsAnnotation.class
);
OrmAnnotationDescriptor<GenericGenerator,GenericGeneratorAnnotation> GENERIC_GENERATOR = new OrmAnnotationDescriptor<>(
GenericGenerator.class,
GenericGeneratorAnnotation.class,
GENERIC_GENERATORS
);
OrmAnnotationDescriptor<HQLSelect,HQLSelectAnnotation> HQL_SELECT = new OrmAnnotationDescriptor<>(
HQLSelect.class,
HQLSelectAnnotation.class
);
OrmAnnotationDescriptor<IdGeneratorType,IdGeneratorTypeAnnotation> ID_GENERATOR_TYPE = new OrmAnnotationDescriptor<>(
IdGeneratorType.class,
IdGeneratorTypeAnnotation.class
);
OrmAnnotationDescriptor<Immutable,ImmutableAnnotation> IMMUTABLE = new OrmAnnotationDescriptor<>(
Immutable.class,
ImmutableAnnotation.class
);
OrmAnnotationDescriptor<Imported,ImportedAnnotation> IMPORTED = new OrmAnnotationDescriptor<>(
Imported.class,
ImportedAnnotation.class
);
OrmAnnotationDescriptor<Index, IndexAnnotation> INDEX = new OrmAnnotationDescriptor<>(
Index.class,
IndexAnnotation.class
);
OrmAnnotationDescriptor<IndexColumn,IndexColumnAnnotation> INDEX_COLUMN = new OrmAnnotationDescriptor<>(
IndexColumn.class,
IndexColumnAnnotation.class
);
OrmAnnotationDescriptor<Instantiator,InstantiatorAnnotation> INSTANTIATOR = new OrmAnnotationDescriptor<>(
Instantiator.class,
InstantiatorAnnotation.class
);
OrmAnnotationDescriptor<JavaType,JavaTypeAnnotation> JAVA_TYPE = new OrmAnnotationDescriptor<>(
JavaType.class,
JavaTypeAnnotation.class
);
OrmAnnotationDescriptor<JavaTypeRegistrations,JavaTypeRegistrationsAnnotation> JAVA_TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
JavaTypeRegistrations.class,
JavaTypeRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<JavaTypeRegistration,JavaTypeRegistrationAnnotation> JAVA_TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
JavaTypeRegistration.class,
JavaTypeRegistrationAnnotation.class,
JAVA_TYPE_REGISTRATIONS
);
OrmAnnotationDescriptor<JdbcType,JdbcTypeAnnotation> JDBC_TYPE = new OrmAnnotationDescriptor<>(
JdbcType.class,
JdbcTypeAnnotation.class
);
OrmAnnotationDescriptor<JdbcTypeCode,JdbcTypeCodeAnnotation> JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
JdbcTypeCode.class,
JdbcTypeCodeAnnotation.class
);
OrmAnnotationDescriptor<JdbcTypeRegistrations,JdbcTypeRegistrationsAnnotation> JDBC_TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
JdbcTypeRegistrations.class,
JdbcTypeRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<JdbcTypeRegistration,JdbcTypeRegistrationAnnotation> JDBC_TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
JdbcTypeRegistration.class,
JdbcTypeRegistrationAnnotation.class,
JDBC_TYPE_REGISTRATIONS
);
OrmAnnotationDescriptor<JoinColumnsOrFormulas, JoinColumnsOrFormulasAnnotation> JOIN_COLUMNS_OR_FORMULAS = new OrmAnnotationDescriptor<>(
JoinColumnsOrFormulas.class,
JoinColumnsOrFormulasAnnotation.class
);
OrmAnnotationDescriptor<JoinColumnOrFormula, JoinColumnOrFormulaAnnotation> JOIN_COLUMN_OR_FORMULA = new OrmAnnotationDescriptor<>(
JoinColumnOrFormula.class,
JoinColumnOrFormulaAnnotation.class,
JOIN_COLUMNS_OR_FORMULAS
);
OrmAnnotationDescriptor<JoinFormula, JoinFormulaAnnotation> JOIN_FORMULA = new OrmAnnotationDescriptor<>(
JoinFormula.class,
JoinFormulaAnnotation.class
);
OrmAnnotationDescriptor<LazyCollection, LazyCollectionAnnotation> LAZY_COLLECTION = new OrmAnnotationDescriptor<>(
LazyCollection.class,
LazyCollectionAnnotation.class
);
OrmAnnotationDescriptor<LazyGroup, LazyGroupAnnotation> LAZY_GROUP = new OrmAnnotationDescriptor<>(
LazyGroup.class,
LazyGroupAnnotation.class
);
OrmAnnotationDescriptor<LazyToOne, LazyToOneAnnotation> LAZY_TO_ONE = new OrmAnnotationDescriptor<>(
LazyToOne.class,
LazyToOneAnnotation.class
);
OrmAnnotationDescriptor<ListIndexBase, ListIndexBaseAnnotation> LIST_INDEX_BASE = new OrmAnnotationDescriptor<>(
ListIndexBase.class,
ListIndexBaseAnnotation.class
);
OrmAnnotationDescriptor<ListIndexJavaType, ListIndexJavaTypeAnnotation> LIST_INDEX_JAVA_TYPE = new OrmAnnotationDescriptor<>(
ListIndexJavaType.class,
ListIndexJavaTypeAnnotation.class
);
OrmAnnotationDescriptor<ListIndexJdbcType, ListIndexJdbcTypeAnnotation> LIST_INDEX_JDBC_TYPE = new OrmAnnotationDescriptor<>(
ListIndexJdbcType.class,
ListIndexJdbcTypeAnnotation.class
);
OrmAnnotationDescriptor<ListIndexJdbcTypeCode, ListIndexJdbcTypeCodeAnnotation> LIST_INDEX_JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
ListIndexJdbcTypeCode.class,
ListIndexJdbcTypeCodeAnnotation.class
);
OrmAnnotationDescriptor<Loader, LoaderAnnotation> LOADER = new OrmAnnotationDescriptor<>(
Loader.class,
LoaderAnnotation.class
);
OrmAnnotationDescriptor<ManyToAny, ManyToAnyAnnotation> MANY_TO_ANY = new OrmAnnotationDescriptor<>(
ManyToAny.class,
ManyToAnyAnnotation.class
);
OrmAnnotationDescriptor<MapKeyCompositeType, MapKeyCompositeTypeAnnotation> MAP_KEY_COMPOSITE_TYPE = new OrmAnnotationDescriptor<>(
MapKeyCompositeType.class,
MapKeyCompositeTypeAnnotation.class
);
OrmAnnotationDescriptor<MapKeyJavaType, MapKeyJavaTypeAnnotation> MAP_KEY_JAVA_TYPE = new OrmAnnotationDescriptor<>(
MapKeyJavaType.class,
MapKeyJavaTypeAnnotation.class
);
OrmAnnotationDescriptor<MapKeyJdbcType, MapKeyJdbcTypeAnnotation> MAP_KEY_JDBC_TYPE = new OrmAnnotationDescriptor<>(
MapKeyJdbcType.class,
MapKeyJdbcTypeAnnotation.class
);
OrmAnnotationDescriptor<MapKeyJdbcTypeCode, MapKeyJdbcTypeCodeAnnotation> MAP_KEY_JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
MapKeyJdbcTypeCode.class,
MapKeyJdbcTypeCodeAnnotation.class
);
OrmAnnotationDescriptor<MapKeyMutability, MapKeyMutabilityAnnotation> MAP_KEY_MUTABILITY = new OrmAnnotationDescriptor<>(
MapKeyMutability.class,
MapKeyMutabilityAnnotation.class
);
OrmAnnotationDescriptor<MapKeyType, MapKeyTypeAnnotation> MAP_KEY_TYPE = new OrmAnnotationDescriptor<>(
MapKeyType.class,
MapKeyTypeAnnotation.class
);
OrmAnnotationDescriptor<Mutability, MutabilityAnnotation> MUTABILITY = new OrmAnnotationDescriptor<>(
Mutability.class,
MutabilityAnnotation.class
);
OrmAnnotationDescriptor<NamedNativeQueries, NamedNativeQueriesAnnotation> NAMED_NATIVE_QUERIES = new OrmAnnotationDescriptor<>(
NamedNativeQueries.class,
NamedNativeQueriesAnnotation.class
);
OrmAnnotationDescriptor<NamedNativeQuery, NamedNativeQueryAnnotation> NAMED_NATIVE_QUERY = new OrmAnnotationDescriptor<>(
NamedNativeQuery.class,
NamedNativeQueryAnnotation.class,
NAMED_NATIVE_QUERIES
);
OrmAnnotationDescriptor<NamedQueries, NamedQueriesAnnotation> NAMED_QUERIES = new OrmAnnotationDescriptor<>(
NamedQueries.class,
NamedQueriesAnnotation.class
);
OrmAnnotationDescriptor<NamedQuery, NamedQueryAnnotation> NAMED_QUERY = new OrmAnnotationDescriptor<>(
NamedQuery.class,
NamedQueryAnnotation.class,
NAMED_QUERIES
);
OrmAnnotationDescriptor<Nationalized, NationalizedAnnotation> NATIONALIZED = new OrmAnnotationDescriptor<>(
Nationalized.class,
NationalizedAnnotation.class
);
OrmAnnotationDescriptor<NaturalId, NaturalIdAnnotation> NATURAL_ID = new OrmAnnotationDescriptor<>(
NaturalId.class,
NaturalIdAnnotation.class
);
OrmAnnotationDescriptor<NaturalIdCache, NaturalIdCacheAnnotation> NATURAL_ID_CACHE = new OrmAnnotationDescriptor<>(
NaturalIdCache.class,
NaturalIdCacheAnnotation.class
);
OrmAnnotationDescriptor<NotFound, NotFoundAnnotation> NOT_FOUND = new OrmAnnotationDescriptor<>(
NotFound.class,
NotFoundAnnotation.class
);
OrmAnnotationDescriptor<OnDelete,OnDeleteAnnotation> ON_DELETE = new OrmAnnotationDescriptor<>(
OnDelete.class,
OnDeleteAnnotation.class
);
OrmAnnotationDescriptor<OptimisticLock,OptimisticLockAnnotation> OPTIMISTIC_LOCK = new OrmAnnotationDescriptor<>(
OptimisticLock.class,
OptimisticLockAnnotation.class
);
OrmAnnotationDescriptor<OptimisticLocking,OptimisticLockingAnnotation> OPTIMISTIC_LOCKING = new OrmAnnotationDescriptor<>(
OptimisticLocking.class,
OptimisticLockingAnnotation.class
);
OrmAnnotationDescriptor<OrderBy,OrderByAnnotation> ORDER_BY = new OrmAnnotationDescriptor<>(
OrderBy.class,
OrderByAnnotation.class
);
OrmAnnotationDescriptor<ParamDef,ParamDefAnnotation> PARAM_DEF = new OrmAnnotationDescriptor<>(
ParamDef.class,
ParamDefAnnotation.class
);
OrmAnnotationDescriptor<Parameter,ParameterAnnotation> PARAMETER = new OrmAnnotationDescriptor<>(
Parameter.class,
ParameterAnnotation.class
);
OrmAnnotationDescriptor<Parent,ParentAnnotation> PARENT = new OrmAnnotationDescriptor<>(
Parent.class,
ParentAnnotation.class
);
OrmAnnotationDescriptor<PartitionKey,PartitionKeyAnnotation> PARTITION_KEY = new OrmAnnotationDescriptor<>(
PartitionKey.class,
PartitionKeyAnnotation.class
);
OrmAnnotationDescriptor<Polymorphism,PolymorphismAnnotation> POLYMORPHISM = new OrmAnnotationDescriptor<>(
Polymorphism.class,
PolymorphismAnnotation.class
);
OrmAnnotationDescriptor<Proxy,ProxyAnnotation> PROXY = new OrmAnnotationDescriptor<>(
Proxy.class,
ProxyAnnotation.class
);
OrmAnnotationDescriptor<QueryCacheLayout,QueryCacheLayoutAnnotation> QUERY_CACHE_LAYOUT = new OrmAnnotationDescriptor<>(
QueryCacheLayout.class,
QueryCacheLayoutAnnotation.class
);
OrmAnnotationDescriptor<RowId,RowIdAnnotation> ROW_ID = new OrmAnnotationDescriptor<>(
RowId.class,
RowIdAnnotation.class
);
OrmAnnotationDescriptor<SecondaryRows,SecondaryRowsAnnotation> SECONDARY_ROWS = new OrmAnnotationDescriptor<>(
SecondaryRows.class,
SecondaryRowsAnnotation.class
);
OrmAnnotationDescriptor<SecondaryRow,SecondaryRowAnnotation> SECONDARY_ROW = new OrmAnnotationDescriptor<>(
SecondaryRow.class,
SecondaryRowAnnotation.class
);
OrmAnnotationDescriptor<SelectBeforeUpdate,SelectBeforeUpdateAnnotation> SELECT_BEFORE_UPDATE = new OrmAnnotationDescriptor<>(
SelectBeforeUpdate.class,
SelectBeforeUpdateAnnotation.class
);
OrmAnnotationDescriptor<SoftDelete,SoftDeleteAnnotation> SOFT_DELETE = new OrmAnnotationDescriptor<>(
SoftDelete.class,
SoftDeleteAnnotation.class
);
OrmAnnotationDescriptor<SortComparator,SortComparatorAnnotation> SORT_COMPARATOR = new OrmAnnotationDescriptor<>(
SortComparator.class,
SortComparatorAnnotation.class
);
OrmAnnotationDescriptor<SortNatural,SortNaturalAnnotation> SORT_NATURAL = new OrmAnnotationDescriptor<>(
SortNatural.class,
SortNaturalAnnotation.class
);
OrmAnnotationDescriptor<Source,SourceAnnotation> SOURCE = new OrmAnnotationDescriptor<>(
Source.class,
SourceAnnotation.class
);
OrmAnnotationDescriptor<SQLDeletes,SQLDeletesAnnotation> SQL_DELETES = new OrmAnnotationDescriptor<>(
SQLDeletes.class,
SQLDeletesAnnotation.class
);
OrmAnnotationDescriptor<SQLDelete,SQLDeleteAnnotation> SQL_DELETE = new OrmAnnotationDescriptor<>(
SQLDelete.class,
SQLDeleteAnnotation.class,
SQL_DELETES
);
OrmAnnotationDescriptor<SQLDeleteAll,SQLDeleteAllAnnotation> SQL_DELETE_ALL = new OrmAnnotationDescriptor<>(
SQLDeleteAll.class,
SQLDeleteAllAnnotation.class
);
OrmAnnotationDescriptor<SqlFragmentAlias,SqlFragmentAliasAnnotation> SQL_FRAGMENT_ALIAS = new OrmAnnotationDescriptor<>(
SqlFragmentAlias.class,
SqlFragmentAliasAnnotation.class
);
OrmAnnotationDescriptor<SQLInserts,SQLInsertsAnnotation> SQL_INSERTS = new OrmAnnotationDescriptor<>(
SQLInserts.class,
SQLInsertsAnnotation.class
);
OrmAnnotationDescriptor<SQLInsert,SQLInsertAnnotation> SQL_INSERT = new OrmAnnotationDescriptor<>(
SQLInsert.class,
SQLInsertAnnotation.class,
SQL_INSERTS
);
OrmAnnotationDescriptor<SQLOrder,SQLOrderAnnotation> SQL_ORDER = new OrmAnnotationDescriptor<>(
SQLOrder.class,
SQLOrderAnnotation.class
);
OrmAnnotationDescriptor<SQLRestriction,SQLRestrictionAnnotation> SQL_RESTRICTION = new OrmAnnotationDescriptor<>(
SQLRestriction.class,
SQLRestrictionAnnotation.class
);
OrmAnnotationDescriptor<SQLSelect,SQLSelectAnnotation> SQL_SELECT = new OrmAnnotationDescriptor<>(
SQLSelect.class,
SQLSelectAnnotation.class
);
OrmAnnotationDescriptor<SQLJoinTableRestriction,SQLJoinTableRestrictionAnnotation> SQL_JOIN_TABLE_RESTRICTION = new OrmAnnotationDescriptor<>(
SQLJoinTableRestriction.class,
SQLJoinTableRestrictionAnnotation.class
);
OrmAnnotationDescriptor<SQLUpdates,SQLUpdatesAnnotation> SQL_UPDATES = new OrmAnnotationDescriptor<>(
SQLUpdates.class,
SQLUpdatesAnnotation.class
);
OrmAnnotationDescriptor<SQLUpdate,SQLUpdateAnnotation> SQL_UPDATE = new OrmAnnotationDescriptor<>(
SQLUpdate.class,
SQLUpdateAnnotation.class,
SQL_UPDATES
);
OrmAnnotationDescriptor<Struct,StructAnnotation> STRUCT = new OrmAnnotationDescriptor<>(
Struct.class,
StructAnnotation.class
);
OrmAnnotationDescriptor<Subselect,SubselectAnnotation> SUBSELECT = new OrmAnnotationDescriptor<>(
Subselect.class,
SubselectAnnotation.class
);
OrmAnnotationDescriptor<Synchronize,SynchronizeAnnotation> SYNCHRONIZE = new OrmAnnotationDescriptor<>(
Synchronize.class,
SynchronizeAnnotation.class
);
OrmAnnotationDescriptor<Tables,TablesAnnotation> TABLES = new OrmAnnotationDescriptor<>(
Tables.class,
TablesAnnotation.class
);
OrmAnnotationDescriptor<Table, TableAnnotation> TABLE = new OrmAnnotationDescriptor<>(
Table.class,
TableAnnotation.class,
TABLES
);
OrmAnnotationDescriptor<Target,TargetLegacyAnnotation> TARGET_LEGACY = new OrmAnnotationDescriptor<>(
Target.class,
TargetLegacyAnnotation.class
);
SpecializedAnnotationDescriptor<TenantId,TenantIdAnnotation> TENANT_ID = new SpecializedAnnotationDescriptor<>(
TenantId.class,
TenantIdAnnotation.class
);
OrmAnnotationDescriptor<TimeZoneColumn,TimeZoneColumnAnnotation> TIME_ZONE_COLUMN = new OrmAnnotationDescriptor<>(
TimeZoneColumn.class,
TimeZoneColumnAnnotation.class
);
OrmAnnotationDescriptor<TimeZoneStorage,TimeZoneStorageAnnotation> TIME_ZONE_STORAGE = new OrmAnnotationDescriptor<>(
TimeZoneStorage.class,
TimeZoneStorageAnnotation.class
);
OrmAnnotationDescriptor<Type,TypeAnnotation> TYPE = new OrmAnnotationDescriptor<>(
Type.class,
TypeAnnotation.class
);
SpecializedAnnotationDescriptor<TypeBinderType,TypeBinderTypeAnnotation> TYPE_BINDER_TYPE = new SpecializedAnnotationDescriptor<>(
TypeBinderType.class,
TypeBinderTypeAnnotation.class
);
OrmAnnotationDescriptor<TypeRegistrations,TypeRegistrationsAnnotation> TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
TypeRegistrations.class,
TypeRegistrationsAnnotation.class
);
OrmAnnotationDescriptor<TypeRegistration,TypeRegistrationAnnotation> TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
TypeRegistration.class,
TypeRegistrationAnnotation.class,
TYPE_REGISTRATIONS
);
OrmAnnotationDescriptor<UpdateTimestamp,UpdateTimestampAnnotation> UPDATE_TIMESTAMP = new OrmAnnotationDescriptor<>(
UpdateTimestamp.class,
UpdateTimestampAnnotation.class
);
OrmAnnotationDescriptor<UuidGenerator,UuidGeneratorAnnotation> UUID_GENERATOR = new OrmAnnotationDescriptor<>(
UuidGenerator.class,
UuidGeneratorAnnotation.class
);
OrmAnnotationDescriptor<ValueGenerationType,ValueGenerationTypeAnnotation> VALUE_GENERATION_TYPE = new OrmAnnotationDescriptor<>(
ValueGenerationType.class,
ValueGenerationTypeAnnotation.class
);
OrmAnnotationDescriptor<View,ViewAnnotation> VIEW = new OrmAnnotationDescriptor<>(
View.class,
ViewAnnotation.class
);
OrmAnnotationDescriptor<Where,WhereAnnotation> WHERE = new OrmAnnotationDescriptor<>(
Where.class,
WhereAnnotation.class
);
OrmAnnotationDescriptor<WhereJoinTable,WhereJoinTableAnnotation> WHERE_JOIN_TABLE = new OrmAnnotationDescriptor<>(
WhereJoinTable.class,
WhereJoinTableAnnotation.class
);
static void forEachAnnotation(Consumer<AnnotationDescriptor<? extends Annotation>> consumer) {
OrmAnnotationHelper.forEachOrmAnnotation( HibernateAnnotations.class, consumer );

View File

@ -9,7 +9,96 @@ package org.hibernate.boot.models;
import java.lang.annotation.Annotation;
import java.util.function.Consumer;
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper;
import org.hibernate.boot.models.annotations.internal.AccessJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.AssociationOverrideJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.AssociationOverridesJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.AttributeOverrideJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.AttributeOverridesJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.BasicJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.CacheableJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.CheckConstraintJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.CollectionTableJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ColumnResultJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ConstructorResultJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ConvertJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ConverterJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ConvertsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.DiscriminatorColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.DiscriminatorValueJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ElementCollectionJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EmbeddableJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EmbeddedIdJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EmbeddedJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EntityJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EntityListenersJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EntityResultJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EnumeratedJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.EnumeratedValueJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ExcludeDefaultListenersJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ExcludeSuperclassListenersJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.FieldResultJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ForeignKeyJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.GeneratedValueJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.IdClassJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.IdJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.IndexJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.InheritanceJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.JoinColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.JoinColumnsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.JoinTableJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.LobJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ManyToManyJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.ManyToOneJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyClassJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyEnumeratedJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyJoinColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyJoinColumnsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyTemporalJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MappedSuperclassJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapsIdJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedAttributeNodeJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedEntityGraphJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedEntityGraphsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedNativeQueriesJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedNativeQueryJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedQueriesJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedQueryJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedStoredProcedureQueriesJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedStoredProcedureQueryJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.NamedSubgraphJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.OneToManyJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.OneToOneJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.OrderByJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.OrderColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PostLoadJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PostPersistJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PostRemoveJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PostUpdateJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PrePersistJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PreRemoveJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PreUpdateJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PrimaryKeyJoinColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.PrimaryKeyJoinColumnsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.QueryHintJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.SecondaryTableJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.SecondaryTablesJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.SequenceGeneratorJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.SequenceGeneratorsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.SqlResultSetMappingJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.SqlResultSetMappingsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.StoredProcedureParameterJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.TableGeneratorJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.TableGeneratorsJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.TableJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.TemporalJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.TransientJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.UniqueConstraintJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.VersionJpaAnnotation;
import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.models.internal.OrmAnnotationDescriptor;
import org.hibernate.models.spi.AnnotationDescriptor;
import jakarta.persistence.Access;
@ -37,6 +126,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EntityResult;
import jakarta.persistence.Enumerated;
import jakarta.persistence.EnumeratedValue;
import jakarta.persistence.ExcludeDefaultListeners;
import jakarta.persistence.ExcludeSuperclassListeners;
import jakarta.persistence.FieldResult;
@ -100,101 +190,379 @@ import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
import static org.hibernate.models.internal.AnnotationHelper.createOrmDescriptor;
/**
* Descriptors for JPA annotations
*
* @author Steve Ebersole
*/
public interface JpaAnnotations {
AnnotationDescriptor<Access> ACCESS = createOrmDescriptor( Access.class );
AnnotationDescriptor<AssociationOverrides> ASSOCIATION_OVERRIDES = createOrmDescriptor( AssociationOverrides.class );
AnnotationDescriptor<AssociationOverride> ASSOCIATION_OVERRIDE = createOrmDescriptor( AssociationOverride.class, ASSOCIATION_OVERRIDES );
AnnotationDescriptor<AttributeOverrides> ATTRIBUTE_OVERRIDES = createOrmDescriptor( AttributeOverrides.class );
AnnotationDescriptor<AttributeOverride> ATTRIBUTE_OVERRIDE = createOrmDescriptor( AttributeOverride.class, ATTRIBUTE_OVERRIDES );
AnnotationDescriptor<Basic> BASIC = createOrmDescriptor( Basic.class );
AnnotationDescriptor<Cacheable> CACHEABLE = createOrmDescriptor( Cacheable.class );
AnnotationDescriptor<CheckConstraint> CHECK_CONSTRAINT = createOrmDescriptor(CheckConstraint.class );
AnnotationDescriptor<CollectionTable> COLLECTION_TABLE = createOrmDescriptor( CollectionTable.class );
AnnotationDescriptor<Column> COLUMN = createOrmDescriptor( Column.class );
AnnotationDescriptor<ColumnResult> COLUMN_RESULT = createOrmDescriptor( ColumnResult.class );
AnnotationDescriptor<ConstructorResult> CONSTRUCTOR_RESULT = createOrmDescriptor( ConstructorResult.class );
AnnotationDescriptor<Converts> CONVERTS = createOrmDescriptor( Converts.class );
AnnotationDescriptor<Convert> CONVERT = createOrmDescriptor( Convert.class, CONVERTS );
AnnotationDescriptor<Converter> CONVERTER = createOrmDescriptor( Converter.class );
AnnotationDescriptor<DiscriminatorColumn> DISCRIMINATOR_COLUMN = createOrmDescriptor( DiscriminatorColumn.class );
AnnotationDescriptor<DiscriminatorValue> DISCRIMINATOR_VALUE = createOrmDescriptor( DiscriminatorValue.class );
AnnotationDescriptor<ElementCollection> ELEMENT_COLLECTION = createOrmDescriptor( ElementCollection.class );
AnnotationDescriptor<Embeddable> EMBEDDABLE = createOrmDescriptor( Embeddable.class );
AnnotationDescriptor<Embedded> EMBEDDED = createOrmDescriptor( Embedded.class );
AnnotationDescriptor<EmbeddedId> EMBEDDED_ID = createOrmDescriptor( EmbeddedId.class );
AnnotationDescriptor<Entity> ENTITY = createOrmDescriptor( Entity.class );
AnnotationDescriptor<EntityListeners> ENTITY_LISTENERS = createOrmDescriptor( EntityListeners.class );
AnnotationDescriptor<EntityResult> ENTITY_RESULT = createOrmDescriptor( EntityResult.class );
AnnotationDescriptor<Enumerated> ENUMERATED = createOrmDescriptor( Enumerated.class );
AnnotationDescriptor<ExcludeDefaultListeners> EXCLUDE_DEFAULT_LISTENERS = createOrmDescriptor( ExcludeDefaultListeners.class );
AnnotationDescriptor<ExcludeSuperclassListeners> EXCLUDE_SUPERCLASS_LISTENERS = createOrmDescriptor( ExcludeSuperclassListeners.class );
AnnotationDescriptor<FieldResult> FIELD_RESULT = createOrmDescriptor( FieldResult.class );
AnnotationDescriptor<ForeignKey> FOREIGN_KEY = createOrmDescriptor( ForeignKey.class );
AnnotationDescriptor<GeneratedValue> GENERATED_VALUE = createOrmDescriptor( GeneratedValue.class );
AnnotationDescriptor<Id> ID = createOrmDescriptor( Id.class );
AnnotationDescriptor<IdClass> ID_CLASS = createOrmDescriptor( IdClass.class );
AnnotationDescriptor<Index> INDEX = createOrmDescriptor( Index.class );
AnnotationDescriptor<Inheritance> INHERITANCE = createOrmDescriptor( Inheritance.class );
AnnotationDescriptor<JoinColumns> JOIN_COLUMNS = createOrmDescriptor( JoinColumns.class );
AnnotationDescriptor<JoinColumn> JOIN_COLUMN = createOrmDescriptor( JoinColumn.class, JOIN_COLUMNS );
AnnotationDescriptor<JoinTable> JOIN_TABLE = createOrmDescriptor( JoinTable.class );
AnnotationDescriptor<Lob> LOB = createOrmDescriptor( Lob.class );
AnnotationDescriptor<ManyToMany> MANY_TO_MANY = createOrmDescriptor( ManyToMany.class );
AnnotationDescriptor<ManyToOne> MANY_TO_ONE = createOrmDescriptor( ManyToOne.class );
AnnotationDescriptor<MapKey> MAP_KEY = createOrmDescriptor( MapKey.class );
AnnotationDescriptor<MapKeyClass> MAP_KEY_CLASS = createOrmDescriptor( MapKeyClass.class );
AnnotationDescriptor<MapKeyColumn> MAP_KEY_COLUMN = createOrmDescriptor( MapKeyColumn.class );
AnnotationDescriptor<MapKeyEnumerated> MAP_KEY_ENUMERATED = createOrmDescriptor( MapKeyEnumerated.class );
AnnotationDescriptor<MapKeyJoinColumns> MAP_KEY_JOIN_COLUMNS = createOrmDescriptor( MapKeyJoinColumns.class );
AnnotationDescriptor<MapKeyJoinColumn> MAP_KEY_JOIN_COLUMN = createOrmDescriptor( MapKeyJoinColumn.class, MAP_KEY_JOIN_COLUMNS );
AnnotationDescriptor<MapKeyTemporal> MAP_KEY_TEMPORAL = createOrmDescriptor( MapKeyTemporal.class );
AnnotationDescriptor<MappedSuperclass> MAPPED_SUPERCLASS = createOrmDescriptor( MappedSuperclass.class );
AnnotationDescriptor<MapsId> MAPS_ID = createOrmDescriptor( MapsId.class );
AnnotationDescriptor<NamedAttributeNode> NAMED_ATTRIBUTE_NODE = createOrmDescriptor( NamedAttributeNode.class );
AnnotationDescriptor<NamedEntityGraphs> NAMED_ENTITY_GRAPHS = createOrmDescriptor( NamedEntityGraphs.class );
AnnotationDescriptor<NamedEntityGraph> NAMED_ENTITY_GRAPH = createOrmDescriptor( NamedEntityGraph.class, NAMED_ENTITY_GRAPHS );
AnnotationDescriptor<NamedNativeQueries> NAMED_NATIVE_QUERIES = createOrmDescriptor( NamedNativeQueries.class );
AnnotationDescriptor<NamedNativeQuery> NAMED_NATIVE_QUERY = createOrmDescriptor( NamedNativeQuery.class, NAMED_NATIVE_QUERIES );
AnnotationDescriptor<NamedQueries> NAMED_QUERIES = createOrmDescriptor( NamedQueries.class );
AnnotationDescriptor<NamedQuery> NAMED_QUERY = createOrmDescriptor( NamedQuery.class, NAMED_QUERIES );
AnnotationDescriptor<NamedStoredProcedureQueries> NAMED_STORED_PROCEDURE_QUERIES = createOrmDescriptor( NamedStoredProcedureQueries.class );
AnnotationDescriptor<NamedStoredProcedureQuery> NAMED_STORED_PROCEDURE_QUERY = createOrmDescriptor( NamedStoredProcedureQuery.class, NAMED_STORED_PROCEDURE_QUERIES );
AnnotationDescriptor<NamedSubgraph> NAMED_SUB_GRAPH = createOrmDescriptor( NamedSubgraph.class );
AnnotationDescriptor<OneToMany> ONE_TO_MANY = createOrmDescriptor( OneToMany.class );
AnnotationDescriptor<OneToOne> ONE_TO_ONE = createOrmDescriptor( OneToOne.class );
AnnotationDescriptor<OrderBy> ORDER_BY = createOrmDescriptor( OrderBy.class );
AnnotationDescriptor<OrderColumn> ORDER_COLUMN = createOrmDescriptor( OrderColumn.class );
AnnotationDescriptor<PostLoad> POST_LOAD = createOrmDescriptor( PostLoad.class );
AnnotationDescriptor<PostPersist> POST_PERSIST = createOrmDescriptor( PostPersist.class );
AnnotationDescriptor<PostRemove> POST_REMOVE = createOrmDescriptor( PostRemove.class );
AnnotationDescriptor<PostUpdate> POST_UPDATE = createOrmDescriptor( PostUpdate.class );
AnnotationDescriptor<PrePersist> PRE_PERSIST = createOrmDescriptor( PrePersist.class );
AnnotationDescriptor<PreRemove> PRE_REMOVE = createOrmDescriptor( PreRemove.class );
AnnotationDescriptor<PreUpdate> PRE_UPDATE = createOrmDescriptor( PreUpdate.class );
AnnotationDescriptor<PrimaryKeyJoinColumns> PRIMARY_KEY_JOIN_COLUMNS = createOrmDescriptor( PrimaryKeyJoinColumns.class );
AnnotationDescriptor<PrimaryKeyJoinColumn> PRIMARY_KEY_JOIN_COLUMN = createOrmDescriptor( PrimaryKeyJoinColumn.class, PRIMARY_KEY_JOIN_COLUMNS );
AnnotationDescriptor<QueryHint> QUERY_HINT = createOrmDescriptor( QueryHint.class );
AnnotationDescriptor<SecondaryTables> SECONDARY_TABLES = createOrmDescriptor( SecondaryTables.class );
AnnotationDescriptor<SecondaryTable> SECONDARY_TABLE = createOrmDescriptor( SecondaryTable.class, SECONDARY_TABLES );
AnnotationDescriptor<SequenceGenerators> SEQUENCE_GENERATORS = createOrmDescriptor( SequenceGenerators.class );
AnnotationDescriptor<SequenceGenerator> SEQUENCE_GENERATOR = createOrmDescriptor( SequenceGenerator.class, SEQUENCE_GENERATORS );
AnnotationDescriptor<SqlResultSetMappings> SQL_RESULT_SET_MAPPINGS = createOrmDescriptor( SqlResultSetMappings.class );
AnnotationDescriptor<SqlResultSetMapping> SQL_RESULT_SET_MAPPING = createOrmDescriptor( SqlResultSetMapping.class, SQL_RESULT_SET_MAPPINGS );
AnnotationDescriptor<StoredProcedureParameter> STORED_PROCEDURE_PARAMETER = createOrmDescriptor( StoredProcedureParameter.class );
AnnotationDescriptor<Table> TABLE = createOrmDescriptor( Table.class );
AnnotationDescriptor<TableGenerators> TABLE_GENERATORS = createOrmDescriptor( TableGenerators.class );
AnnotationDescriptor<TableGenerator> TABLE_GENERATOR = createOrmDescriptor( TableGenerator.class, TABLE_GENERATORS );
AnnotationDescriptor<Temporal> TEMPORAL = createOrmDescriptor( Temporal.class );
AnnotationDescriptor<Transient> TRANSIENT = createOrmDescriptor( Transient.class );
AnnotationDescriptor<UniqueConstraint> UNIQUE_CONSTRAINT = createOrmDescriptor( UniqueConstraint.class );
AnnotationDescriptor<Version> VERSION = createOrmDescriptor( Version.class );
OrmAnnotationDescriptor<Access,AccessJpaAnnotation> ACCESS = new OrmAnnotationDescriptor<>(
Access.class,
AccessJpaAnnotation.class
);
OrmAnnotationDescriptor<AssociationOverrides,AssociationOverridesJpaAnnotation> ASSOCIATION_OVERRIDES = new OrmAnnotationDescriptor<>(
AssociationOverrides.class,
AssociationOverridesJpaAnnotation.class
);
OrmAnnotationDescriptor<AssociationOverride,AssociationOverrideJpaAnnotation> ASSOCIATION_OVERRIDE = new OrmAnnotationDescriptor<>(
AssociationOverride.class,
AssociationOverrideJpaAnnotation.class,
ASSOCIATION_OVERRIDES
);
OrmAnnotationDescriptor<AttributeOverrides,AttributeOverridesJpaAnnotation> ATTRIBUTE_OVERRIDES = new OrmAnnotationDescriptor<>(
AttributeOverrides.class,
AttributeOverridesJpaAnnotation.class
);
OrmAnnotationDescriptor<AttributeOverride,AttributeOverrideJpaAnnotation> ATTRIBUTE_OVERRIDE = new OrmAnnotationDescriptor<>(
AttributeOverride.class,
AttributeOverrideJpaAnnotation.class,
ATTRIBUTE_OVERRIDES
);
OrmAnnotationDescriptor<Basic,BasicJpaAnnotation> BASIC = new OrmAnnotationDescriptor<>(
Basic.class,
BasicJpaAnnotation.class
);
OrmAnnotationDescriptor<Cacheable,CacheableJpaAnnotation> CACHEABLE = new OrmAnnotationDescriptor<>(
Cacheable.class,
CacheableJpaAnnotation.class
);
OrmAnnotationDescriptor<CheckConstraint,CheckConstraintJpaAnnotation> CHECK_CONSTRAINT = new OrmAnnotationDescriptor<>(
CheckConstraint.class,
CheckConstraintJpaAnnotation.class
);
OrmAnnotationDescriptor<CollectionTable,CollectionTableJpaAnnotation> COLLECTION_TABLE = new OrmAnnotationDescriptor<>(
CollectionTable.class,
CollectionTableJpaAnnotation.class
);
OrmAnnotationDescriptor<Column,ColumnJpaAnnotation> COLUMN = new OrmAnnotationDescriptor<>(
Column.class,
ColumnJpaAnnotation.class
);
OrmAnnotationDescriptor<ColumnResult,ColumnResultJpaAnnotation> COLUMN_RESULT = new OrmAnnotationDescriptor<>(
ColumnResult.class,
ColumnResultJpaAnnotation.class
);
OrmAnnotationDescriptor<ConstructorResult,ConstructorResultJpaAnnotation> CONSTRUCTOR_RESULT = new OrmAnnotationDescriptor<>(
ConstructorResult.class,
ConstructorResultJpaAnnotation.class
);
OrmAnnotationDescriptor<Converts,ConvertsJpaAnnotation> CONVERTS = new OrmAnnotationDescriptor<>(
Converts.class,
ConvertsJpaAnnotation.class
);
OrmAnnotationDescriptor<Convert,ConvertJpaAnnotation> CONVERT = new OrmAnnotationDescriptor<>(
Convert.class,
ConvertJpaAnnotation.class,
CONVERTS
);
OrmAnnotationDescriptor<Converter,ConverterJpaAnnotation> CONVERTER = new OrmAnnotationDescriptor<>(
Converter.class,
ConverterJpaAnnotation.class
);
OrmAnnotationDescriptor<DiscriminatorColumn,DiscriminatorColumnJpaAnnotation> DISCRIMINATOR_COLUMN = new OrmAnnotationDescriptor<>(
DiscriminatorColumn.class,
DiscriminatorColumnJpaAnnotation.class
);
OrmAnnotationDescriptor<DiscriminatorValue,DiscriminatorValueJpaAnnotation> DISCRIMINATOR_VALUE = new OrmAnnotationDescriptor<>(
DiscriminatorValue.class,
DiscriminatorValueJpaAnnotation.class
);
OrmAnnotationDescriptor<ElementCollection,ElementCollectionJpaAnnotation> ELEMENT_COLLECTION = new OrmAnnotationDescriptor<>(
ElementCollection.class,
ElementCollectionJpaAnnotation.class
);
OrmAnnotationDescriptor<Embeddable,EmbeddableJpaAnnotation> EMBEDDABLE = new OrmAnnotationDescriptor<>(
Embeddable.class,
EmbeddableJpaAnnotation.class
);
OrmAnnotationDescriptor<Embedded,EmbeddedJpaAnnotation> EMBEDDED = new OrmAnnotationDescriptor<>(
Embedded.class,
EmbeddedJpaAnnotation.class
);
OrmAnnotationDescriptor<EmbeddedId,EmbeddedIdJpaAnnotation> EMBEDDED_ID = new OrmAnnotationDescriptor<>(
EmbeddedId.class,
EmbeddedIdJpaAnnotation.class
);
OrmAnnotationDescriptor<Entity,EntityJpaAnnotation> ENTITY = new OrmAnnotationDescriptor<>(
Entity.class,
EntityJpaAnnotation.class
);
OrmAnnotationDescriptor<EntityListeners,EntityListenersJpaAnnotation> ENTITY_LISTENERS = new OrmAnnotationDescriptor<>(
EntityListeners.class,
EntityListenersJpaAnnotation.class
);
OrmAnnotationDescriptor<EntityResult,EntityResultJpaAnnotation> ENTITY_RESULT = new OrmAnnotationDescriptor<>(
EntityResult.class,
EntityResultJpaAnnotation.class
);
OrmAnnotationDescriptor<Enumerated,EnumeratedJpaAnnotation> ENUMERATED = new OrmAnnotationDescriptor<>(
Enumerated.class,
EnumeratedJpaAnnotation.class
);
OrmAnnotationDescriptor<EnumeratedValue, EnumeratedValueJpaAnnotation> ENUMERATED_VALUE = new OrmAnnotationDescriptor<>(
EnumeratedValue.class,
EnumeratedValueJpaAnnotation.class
);
OrmAnnotationDescriptor<ExcludeDefaultListeners,ExcludeDefaultListenersJpaAnnotation> EXCLUDE_DEFAULT_LISTENERS = new OrmAnnotationDescriptor<>(
ExcludeDefaultListeners.class,
ExcludeDefaultListenersJpaAnnotation.class
);
OrmAnnotationDescriptor<ExcludeSuperclassListeners,ExcludeSuperclassListenersJpaAnnotation> EXCLUDE_SUPERCLASS_LISTENERS = new OrmAnnotationDescriptor<>(
ExcludeSuperclassListeners.class,
ExcludeSuperclassListenersJpaAnnotation.class
);
OrmAnnotationDescriptor<FieldResult,FieldResultJpaAnnotation> FIELD_RESULT = new OrmAnnotationDescriptor<>(
FieldResult.class,
FieldResultJpaAnnotation.class
);
OrmAnnotationDescriptor<ForeignKey,ForeignKeyJpaAnnotation> FOREIGN_KEY = new OrmAnnotationDescriptor<>(
ForeignKey.class,
ForeignKeyJpaAnnotation.class
);
OrmAnnotationDescriptor<GeneratedValue,GeneratedValueJpaAnnotation> GENERATED_VALUE = new OrmAnnotationDescriptor<>(
GeneratedValue.class,
GeneratedValueJpaAnnotation.class
);
OrmAnnotationDescriptor<Id,IdJpaAnnotation> ID = new OrmAnnotationDescriptor<>(
Id.class,
IdJpaAnnotation.class
);
OrmAnnotationDescriptor<IdClass,IdClassJpaAnnotation> ID_CLASS = new OrmAnnotationDescriptor<>(
IdClass.class,
IdClassJpaAnnotation.class
);
OrmAnnotationDescriptor<Index,IndexJpaAnnotation> INDEX = new OrmAnnotationDescriptor<>(
Index.class,
IndexJpaAnnotation.class
);
OrmAnnotationDescriptor<Inheritance,InheritanceJpaAnnotation> INHERITANCE = new OrmAnnotationDescriptor<>(
Inheritance.class,
InheritanceJpaAnnotation.class
);
OrmAnnotationDescriptor<JoinColumns,JoinColumnsJpaAnnotation> JOIN_COLUMNS = new OrmAnnotationDescriptor<>(
JoinColumns.class,
JoinColumnsJpaAnnotation.class
);
OrmAnnotationDescriptor<JoinColumn,JoinColumnJpaAnnotation> JOIN_COLUMN = new OrmAnnotationDescriptor<>(
JoinColumn.class,
JoinColumnJpaAnnotation.class,
JOIN_COLUMNS
);
OrmAnnotationDescriptor<JoinTable,JoinTableJpaAnnotation> JOIN_TABLE = new OrmAnnotationDescriptor<>(
JoinTable.class,
JoinTableJpaAnnotation.class
);
OrmAnnotationDescriptor<Lob,LobJpaAnnotation> LOB = new OrmAnnotationDescriptor<>(
Lob.class,
LobJpaAnnotation.class
);
OrmAnnotationDescriptor<ManyToMany,ManyToManyJpaAnnotation> MANY_TO_MANY = new OrmAnnotationDescriptor<>(
ManyToMany.class,
ManyToManyJpaAnnotation.class
);
OrmAnnotationDescriptor<ManyToOne,ManyToOneJpaAnnotation> MANY_TO_ONE = new OrmAnnotationDescriptor<>(
ManyToOne.class,
ManyToOneJpaAnnotation.class
);
OrmAnnotationDescriptor<MapKey,MapKeyJpaAnnotation> MAP_KEY = new OrmAnnotationDescriptor<>(
MapKey.class,
MapKeyJpaAnnotation.class
);
OrmAnnotationDescriptor<MapKeyClass,MapKeyClassJpaAnnotation> MAP_KEY_CLASS = new OrmAnnotationDescriptor<>(
MapKeyClass.class,
MapKeyClassJpaAnnotation.class
);
OrmAnnotationDescriptor<MapKeyColumn,MapKeyColumnJpaAnnotation> MAP_KEY_COLUMN = new OrmAnnotationDescriptor<>(
MapKeyColumn.class,
MapKeyColumnJpaAnnotation.class
);
OrmAnnotationDescriptor<MapKeyEnumerated,MapKeyEnumeratedJpaAnnotation> MAP_KEY_ENUMERATED = new OrmAnnotationDescriptor<>(
MapKeyEnumerated.class,
MapKeyEnumeratedJpaAnnotation.class
);
OrmAnnotationDescriptor<MapKeyJoinColumns,MapKeyJoinColumnsJpaAnnotation> MAP_KEY_JOIN_COLUMNS = new OrmAnnotationDescriptor<>(
MapKeyJoinColumns.class,
MapKeyJoinColumnsJpaAnnotation.class
);
OrmAnnotationDescriptor<MapKeyJoinColumn, MapKeyJoinColumnJpaAnnotation> MAP_KEY_JOIN_COLUMN = new OrmAnnotationDescriptor<>(
MapKeyJoinColumn.class,
MapKeyJoinColumnJpaAnnotation.class,
MAP_KEY_JOIN_COLUMNS
);
OrmAnnotationDescriptor<MapKeyTemporal,MapKeyTemporalJpaAnnotation> MAP_KEY_TEMPORAL = new OrmAnnotationDescriptor<>(
MapKeyTemporal.class,
MapKeyTemporalJpaAnnotation.class
);
OrmAnnotationDescriptor<MappedSuperclass,MappedSuperclassJpaAnnotation> MAPPED_SUPERCLASS = new OrmAnnotationDescriptor<>(
MappedSuperclass.class,
MappedSuperclassJpaAnnotation.class
);
OrmAnnotationDescriptor<MapsId,MapsIdJpaAnnotation> MAPS_ID = new OrmAnnotationDescriptor<>(
MapsId.class,
MapsIdJpaAnnotation.class
);
OrmAnnotationDescriptor<NamedAttributeNode,NamedAttributeNodeJpaAnnotation> NAMED_ATTRIBUTE_NODE = new OrmAnnotationDescriptor<>(
NamedAttributeNode.class,
NamedAttributeNodeJpaAnnotation.class
);
OrmAnnotationDescriptor<NamedEntityGraphs,NamedEntityGraphsJpaAnnotation> NAMED_ENTITY_GRAPHS = new OrmAnnotationDescriptor<>(
NamedEntityGraphs.class,
NamedEntityGraphsJpaAnnotation.class
);
OrmAnnotationDescriptor<NamedEntityGraph,NamedEntityGraphJpaAnnotation> NAMED_ENTITY_GRAPH = new OrmAnnotationDescriptor<>(
NamedEntityGraph.class,
NamedEntityGraphJpaAnnotation.class,
NAMED_ENTITY_GRAPHS
);
OrmAnnotationDescriptor<NamedNativeQueries,NamedNativeQueriesJpaAnnotation> NAMED_NATIVE_QUERIES = new OrmAnnotationDescriptor<>(
NamedNativeQueries.class,
NamedNativeQueriesJpaAnnotation.class
);
OrmAnnotationDescriptor<NamedNativeQuery,NamedNativeQueryJpaAnnotation> NAMED_NATIVE_QUERY = new OrmAnnotationDescriptor<>(
NamedNativeQuery.class,
NamedNativeQueryJpaAnnotation.class,
NAMED_NATIVE_QUERIES
);
OrmAnnotationDescriptor<NamedQueries,NamedQueriesJpaAnnotation> NAMED_QUERIES = new OrmAnnotationDescriptor<>(
NamedQueries.class,
NamedQueriesJpaAnnotation.class
);
OrmAnnotationDescriptor<NamedQuery,NamedQueryJpaAnnotation> NAMED_QUERY = new OrmAnnotationDescriptor<>(
NamedQuery.class,
NamedQueryJpaAnnotation.class,
NAMED_QUERIES
);
OrmAnnotationDescriptor<NamedStoredProcedureQueries,NamedStoredProcedureQueriesJpaAnnotation> NAMED_STORED_PROCEDURE_QUERIES = new OrmAnnotationDescriptor<>(
NamedStoredProcedureQueries.class,
NamedStoredProcedureQueriesJpaAnnotation.class
);
OrmAnnotationDescriptor<NamedStoredProcedureQuery,NamedStoredProcedureQueryJpaAnnotation> NAMED_STORED_PROCEDURE_QUERY = new OrmAnnotationDescriptor<>(
NamedStoredProcedureQuery.class,
NamedStoredProcedureQueryJpaAnnotation.class,
NAMED_STORED_PROCEDURE_QUERIES
);
OrmAnnotationDescriptor<NamedSubgraph,NamedSubgraphJpaAnnotation> NAMED_SUBGRAPH = new OrmAnnotationDescriptor<>(
NamedSubgraph.class,
NamedSubgraphJpaAnnotation.class
);
OrmAnnotationDescriptor<OneToMany,OneToManyJpaAnnotation> ONE_TO_MANY = new OrmAnnotationDescriptor<>(
OneToMany.class,
OneToManyJpaAnnotation.class
);
OrmAnnotationDescriptor<OneToOne, OneToOneJpaAnnotation> ONE_TO_ONE = new OrmAnnotationDescriptor<>(
OneToOne.class,
OneToOneJpaAnnotation.class
);
OrmAnnotationDescriptor<OrderBy,OrderByJpaAnnotation> ORDER_BY = new OrmAnnotationDescriptor<>(
OrderBy.class,
OrderByJpaAnnotation.class
);
OrmAnnotationDescriptor<OrderColumn,OrderColumnJpaAnnotation> ORDER_COLUMN = new OrmAnnotationDescriptor<>(
OrderColumn.class,
OrderColumnJpaAnnotation.class
);
OrmAnnotationDescriptor<PostLoad,PostLoadJpaAnnotation> POST_LOAD = new OrmAnnotationDescriptor<>(
PostLoad.class,
PostLoadJpaAnnotation.class
);
OrmAnnotationDescriptor<PostPersist,PostPersistJpaAnnotation> POST_PERSIST = new OrmAnnotationDescriptor<>(
PostPersist.class,
PostPersistJpaAnnotation.class
);
OrmAnnotationDescriptor<PostRemove,PostRemoveJpaAnnotation> POST_REMOVE = new OrmAnnotationDescriptor<>(
PostRemove.class,
PostRemoveJpaAnnotation.class
);
OrmAnnotationDescriptor<PostUpdate,PostUpdateJpaAnnotation> POST_UPDATE = new OrmAnnotationDescriptor<>(
PostUpdate.class,
PostUpdateJpaAnnotation.class
);
OrmAnnotationDescriptor<PrePersist,PrePersistJpaAnnotation> PRE_PERSIST = new OrmAnnotationDescriptor<>(
PrePersist.class,
PrePersistJpaAnnotation.class
);
OrmAnnotationDescriptor<PreRemove,PreRemoveJpaAnnotation> PRE_REMOVE = new OrmAnnotationDescriptor<>(
PreRemove.class,
PreRemoveJpaAnnotation.class
);
OrmAnnotationDescriptor<PreUpdate,PreUpdateJpaAnnotation> PRE_UPDATE = new OrmAnnotationDescriptor<>(
PreUpdate.class,
PreUpdateJpaAnnotation.class
);
OrmAnnotationDescriptor<PrimaryKeyJoinColumns,PrimaryKeyJoinColumnsJpaAnnotation> PRIMARY_KEY_JOIN_COLUMNS = new OrmAnnotationDescriptor<>(
PrimaryKeyJoinColumns.class,
PrimaryKeyJoinColumnsJpaAnnotation.class
);
OrmAnnotationDescriptor<PrimaryKeyJoinColumn, PrimaryKeyJoinColumnJpaAnnotation> PRIMARY_KEY_JOIN_COLUMN = new OrmAnnotationDescriptor<>(
PrimaryKeyJoinColumn.class,
PrimaryKeyJoinColumnJpaAnnotation.class,
PRIMARY_KEY_JOIN_COLUMNS
);
OrmAnnotationDescriptor<QueryHint,QueryHintJpaAnnotation> QUERY_HINT = new OrmAnnotationDescriptor<>(
QueryHint.class,
QueryHintJpaAnnotation.class
);
OrmAnnotationDescriptor<SecondaryTables,SecondaryTablesJpaAnnotation> SECONDARY_TABLES = new OrmAnnotationDescriptor<>(
SecondaryTables.class,
SecondaryTablesJpaAnnotation.class
);
OrmAnnotationDescriptor<SecondaryTable,SecondaryTableJpaAnnotation> SECONDARY_TABLE = new OrmAnnotationDescriptor<>(
SecondaryTable.class,
SecondaryTableJpaAnnotation.class,
SECONDARY_TABLES
);
OrmAnnotationDescriptor<SequenceGenerators,SequenceGeneratorsJpaAnnotation> SEQUENCE_GENERATORS = new OrmAnnotationDescriptor<>(
SequenceGenerators.class,
SequenceGeneratorsJpaAnnotation.class
);
OrmAnnotationDescriptor<SequenceGenerator,SequenceGeneratorJpaAnnotation> SEQUENCE_GENERATOR = new OrmAnnotationDescriptor<>(
SequenceGenerator.class,
SequenceGeneratorJpaAnnotation.class,
SEQUENCE_GENERATORS
);
OrmAnnotationDescriptor<SqlResultSetMappings,SqlResultSetMappingsJpaAnnotation> SQL_RESULT_SET_MAPPINGS = new OrmAnnotationDescriptor<>(
SqlResultSetMappings.class,
SqlResultSetMappingsJpaAnnotation.class
);
OrmAnnotationDescriptor<SqlResultSetMapping,SqlResultSetMappingJpaAnnotation> SQL_RESULT_SET_MAPPING = new OrmAnnotationDescriptor<>(
SqlResultSetMapping.class,
SqlResultSetMappingJpaAnnotation.class,
SQL_RESULT_SET_MAPPINGS
);
OrmAnnotationDescriptor<StoredProcedureParameter,StoredProcedureParameterJpaAnnotation> STORED_PROCEDURE_PARAMETER = new OrmAnnotationDescriptor<>(
StoredProcedureParameter.class,
StoredProcedureParameterJpaAnnotation.class
);
OrmAnnotationDescriptor<Table,TableJpaAnnotation> TABLE = new OrmAnnotationDescriptor<>(
Table.class,
TableJpaAnnotation.class
);
OrmAnnotationDescriptor<TableGenerators,TableGeneratorsJpaAnnotation> TABLE_GENERATORS = new OrmAnnotationDescriptor<>(
TableGenerators.class,
TableGeneratorsJpaAnnotation.class
);
OrmAnnotationDescriptor<TableGenerator,TableGeneratorJpaAnnotation> TABLE_GENERATOR = new OrmAnnotationDescriptor<>(
TableGenerator.class,
TableGeneratorJpaAnnotation.class,
TABLE_GENERATORS
);
OrmAnnotationDescriptor<Temporal,TemporalJpaAnnotation> TEMPORAL = new OrmAnnotationDescriptor<>(
Temporal.class,
TemporalJpaAnnotation.class
);
OrmAnnotationDescriptor<Transient,TransientJpaAnnotation> TRANSIENT = new OrmAnnotationDescriptor<>(
Transient.class,
TransientJpaAnnotation.class
);
OrmAnnotationDescriptor<UniqueConstraint,UniqueConstraintJpaAnnotation> UNIQUE_CONSTRAINT = new OrmAnnotationDescriptor<>(
UniqueConstraint.class,
UniqueConstraintJpaAnnotation.class
);
OrmAnnotationDescriptor<Version,VersionJpaAnnotation> VERSION = new OrmAnnotationDescriptor<>(
Version.class,
VersionJpaAnnotation.class
);
static void forEachAnnotation(Consumer<AnnotationDescriptor<? extends Annotation>> consumer) {
OrmAnnotationHelper.forEachOrmAnnotation( JpaAnnotations.class, consumer );

View File

@ -0,0 +1,53 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models;
import java.util.function.Consumer;
import org.hibernate.boot.internal.Abstract;
import org.hibernate.boot.internal.AnyKeyType;
import org.hibernate.boot.internal.CollectionClassification;
import org.hibernate.boot.internal.Extends;
import org.hibernate.boot.internal.Target;
import org.hibernate.boot.models.annotations.internal.AbstractXmlAnnotation;
import org.hibernate.boot.models.annotations.internal.AnyKeyTypeXmlAnnotation;
import org.hibernate.boot.models.annotations.internal.CollectionClassificationXmlAnnotation;
import org.hibernate.boot.models.annotations.internal.ExtendsXmlAnnotation;
import org.hibernate.boot.models.annotations.internal.TargetXmlAnnotation;
import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.models.internal.OrmAnnotationDescriptor;
import org.hibernate.models.spi.AnnotationDescriptor;
/**
* @author Steve Ebersole
*/
public interface XmlAnnotations {
OrmAnnotationDescriptor<Abstract, AbstractXmlAnnotation> ABSTRACT = new OrmAnnotationDescriptor<>(
Abstract.class,
AbstractXmlAnnotation.class
);
OrmAnnotationDescriptor<AnyKeyType, AnyKeyTypeXmlAnnotation> ANY_KEY_TYPE = new OrmAnnotationDescriptor<>(
AnyKeyType.class,
AnyKeyTypeXmlAnnotation.class
);
OrmAnnotationDescriptor<CollectionClassification, CollectionClassificationXmlAnnotation> COLLECTION_CLASSIFICATION = new OrmAnnotationDescriptor<>(
CollectionClassification.class,
CollectionClassificationXmlAnnotation.class
);
OrmAnnotationDescriptor<Extends, ExtendsXmlAnnotation> EXTENDS = new OrmAnnotationDescriptor<>(
Extends.class,
ExtendsXmlAnnotation.class
);
OrmAnnotationDescriptor<Target, TargetXmlAnnotation> TARGET = new OrmAnnotationDescriptor<>(
Target.class,
TargetXmlAnnotation.class
);
static void forEachAnnotation(Consumer<AnnotationDescriptor<?>> consumer) {
OrmAnnotationHelper.forEachOrmAnnotation( XmlAnnotations.class, consumer );
}
}

View File

@ -0,0 +1,25 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.internal.Abstract;
import org.hibernate.models.spi.SourceModelBuildingContext;
/**
* @author Steve Ebersole
*/
public class AbstractXmlAnnotation implements Abstract {
public AbstractXmlAnnotation(SourceModelBuildingContext modelContext) {
}
@Override
public Class<? extends Annotation> annotationType() {
return Abstract.class;
}
}

View File

@ -0,0 +1,60 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import jakarta.persistence.Access;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AccessJpaAnnotation implements Access {
private jakarta.persistence.AccessType value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AccessJpaAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AccessJpaAnnotation(Access annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue( annotation, JpaAnnotations.ACCESS, "value", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AccessJpaAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, JpaAnnotations.ACCESS, "value", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return Access.class;
}
@Override
public jakarta.persistence.AccessType value() {
return value;
}
public void value(jakarta.persistence.AccessType value) {
this.value = value;
}
}

View File

@ -0,0 +1,77 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.annotations.spi.AttributeMarker;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.Any;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyAnnotation implements Any, AttributeMarker, AttributeMarker.Fetchable, AttributeMarker.Optionalable {
private jakarta.persistence.FetchType fetch;
private boolean optional;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyAnnotation(SourceModelBuildingContext modelContext) {
this.fetch = jakarta.persistence.FetchType.EAGER;
this.optional = true;
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyAnnotation(Any annotation, SourceModelBuildingContext modelContext) {
this.fetch = extractJdkValue( annotation, HibernateAnnotations.ANY, "fetch", modelContext );
this.optional = extractJdkValue( annotation, HibernateAnnotations.ANY, "optional", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.fetch = extractJandexValue( annotation, HibernateAnnotations.ANY, "fetch", modelContext );
this.optional = extractJandexValue( annotation, HibernateAnnotations.ANY, "optional", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return Any.class;
}
@Override
public jakarta.persistence.FetchType fetch() {
return fetch;
}
public void fetch(jakarta.persistence.FetchType value) {
this.fetch = value;
}
@Override
public boolean optional() {
return optional;
}
public void optional(boolean value) {
this.optional = value;
}
}

View File

@ -0,0 +1,62 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyDiscriminator;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyDiscriminatorAnnotation implements AnyDiscriminator {
private jakarta.persistence.DiscriminatorType value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyDiscriminatorAnnotation(SourceModelBuildingContext modelContext) {
this.value = jakarta.persistence.DiscriminatorType.STRING;
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyDiscriminatorAnnotation(AnyDiscriminator annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue( annotation, HibernateAnnotations.ANY_DISCRIMINATOR, "value", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyDiscriminatorAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, HibernateAnnotations.ANY_DISCRIMINATOR, "value", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyDiscriminator.class;
}
@Override
public jakarta.persistence.DiscriminatorType value() {
return value;
}
public void value(jakarta.persistence.DiscriminatorType value) {
this.value = value;
}
}

View File

@ -0,0 +1,94 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyDiscriminatorValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyDiscriminatorValueAnnotation implements AnyDiscriminatorValue {
private String discriminator;
private java.lang.Class<?> entity;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyDiscriminatorValueAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyDiscriminatorValueAnnotation(AnyDiscriminatorValue annotation, SourceModelBuildingContext modelContext) {
this.discriminator = extractJdkValue(
annotation,
HibernateAnnotations.ANY_DISCRIMINATOR_VALUE,
"discriminator",
modelContext
);
this.entity = extractJdkValue(
annotation,
HibernateAnnotations.ANY_DISCRIMINATOR_VALUE,
"entity",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyDiscriminatorValueAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.discriminator = extractJandexValue(
annotation,
HibernateAnnotations.ANY_DISCRIMINATOR_VALUE,
"discriminator",
modelContext
);
this.entity = extractJandexValue(
annotation,
HibernateAnnotations.ANY_DISCRIMINATOR_VALUE,
"entity",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyDiscriminatorValue.class;
}
@Override
public String discriminator() {
return discriminator;
}
public void discriminator(String value) {
this.discriminator = value;
}
@Override
public java.lang.Class<?> entity() {
return entity;
}
public void entity(java.lang.Class<?> value) {
this.entity = value;
}
}

View File

@ -0,0 +1,76 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.annotations.AnyDiscriminatorValue;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.annotations.spi.RepeatableContainer;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyDiscriminatorValues;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyDiscriminatorValuesAnnotation
implements AnyDiscriminatorValues, RepeatableContainer<AnyDiscriminatorValue> {
private org.hibernate.annotations.AnyDiscriminatorValue[] value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyDiscriminatorValuesAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyDiscriminatorValuesAnnotation(
AnyDiscriminatorValues annotation,
SourceModelBuildingContext modelContext) {
this.value = extractJdkValue(
annotation,
HibernateAnnotations.ANY_DISCRIMINATOR_VALUES,
"value",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyDiscriminatorValuesAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue(
annotation,
HibernateAnnotations.ANY_DISCRIMINATOR_VALUES,
"value",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyDiscriminatorValues.class;
}
@Override
public org.hibernate.annotations.AnyDiscriminatorValue[] value() {
return value;
}
public void value(org.hibernate.annotations.AnyDiscriminatorValue[] value) {
this.value = value;
}
}

View File

@ -0,0 +1,63 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.XmlAnnotations;
import org.hibernate.models.internal.OrmAnnotationDescriptor;
import org.hibernate.models.spi.AnnotationDescriptor;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import org.hibernate.boot.internal.AnyKeyType;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyKeTypeAnnotation implements AnyKeyType {
private String value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyKeTypeAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyKeTypeAnnotation(AnyKeyType annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue( annotation, XmlAnnotations.ANY_KEY_TYPE, "value", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyKeTypeAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, XmlAnnotations.ANY_KEY_TYPE, "value", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyKeyType.class;
}
@Override
public String value() {
return value;
}
public void value(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,70 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyKeyJavaClass;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyKeyJavaClassAnnotation implements AnyKeyJavaClass {
private java.lang.Class<?> value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyKeyJavaClassAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyKeyJavaClassAnnotation(AnyKeyJavaClass annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JAVA_CLASS,
"value",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyKeyJavaClassAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JAVA_CLASS,
"value",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyKeyJavaClass.class;
}
@Override
public java.lang.Class<?> value() {
return value;
}
public void value(java.lang.Class<?> value) {
this.value = value;
}
}

View File

@ -0,0 +1,71 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyKeyJavaType;
import org.hibernate.type.descriptor.java.BasicJavaType;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyKeyJavaTypeAnnotation implements AnyKeyJavaType {
private Class<? extends BasicJavaType<?>> value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyKeyJavaTypeAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyKeyJavaTypeAnnotation(AnyKeyJavaType annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JAVA_TYPE,
"value",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyKeyJavaTypeAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JAVA_TYPE,
"value",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyKeyJavaType.class;
}
@Override
public Class<? extends BasicJavaType<?>> value() {
return value;
}
public void value(Class<? extends BasicJavaType<?>> value) {
this.value = value;
}
}

View File

@ -0,0 +1,71 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyKeyJdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyKeyJdbcTypeAnnotation implements AnyKeyJdbcType {
private Class<? extends JdbcType> value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyKeyJdbcTypeAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyKeyJdbcTypeAnnotation(AnyKeyJdbcType annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JDBC_TYPE,
"value",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyKeyJdbcTypeAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JDBC_TYPE,
"value",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyKeyJdbcType.class;
}
@Override
public Class<? extends JdbcType> value() {
return value;
}
public void value(Class<? extends JdbcType> value) {
this.value = value;
}
}

View File

@ -0,0 +1,70 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AnyKeyJdbcTypeCode;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AnyKeyJdbcTypeCodeAnnotation implements AnyKeyJdbcTypeCode {
private int value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyKeyJdbcTypeCodeAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyKeyJdbcTypeCodeAnnotation(AnyKeyJdbcTypeCode annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JDBC_TYPE_CODE,
"value",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyKeyJdbcTypeCodeAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ANY_KEY_JDBC_TYPE_CODE,
"value",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AnyKeyJdbcTypeCode.class;
}
@Override
public int value() {
return value;
}
public void value(int value) {
this.value = value;
}
}

View File

@ -0,0 +1,69 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.internal.Abstract;
import org.hibernate.boot.internal.AnyKeyType;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
/**
* @author Steve Ebersole
*/
public class AnyKeyTypeXmlAnnotation implements AnyKeyType {
private String value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AnyKeyTypeXmlAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AnyKeyTypeXmlAnnotation(AnyKeyType annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue(
annotation,
org.hibernate.boot.models.XmlAnnotations.ANY_KEY_TYPE,
"value",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AnyKeyTypeXmlAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue(
annotation,
org.hibernate.boot.models.XmlAnnotations.ANY_KEY_TYPE,
"value",
modelContext
);
}
@Override
public String value() {
return value;
}
public void value(String value) {
this.value = value;
}
@Override
public Class<? extends Annotation> annotationType() {
return Abstract.class;
}
}

View File

@ -0,0 +1,64 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.AnnotationDescriptor;
import org.hibernate.models.spi.AttributeDescriptor;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.Array;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class ArrayAnnotation implements Array {
private int length;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public ArrayAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public ArrayAnnotation(Array annotation, SourceModelBuildingContext modelContext) {
this.length = extractJdkValue( annotation, HibernateAnnotations.ARRAY, "length", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public ArrayAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.length = extractJandexValue( annotation, HibernateAnnotations.ARRAY, "length", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return Array.class;
}
@Override
public int length() {
return length;
}
public void length(int value) {
this.length = value;
}
}

View File

@ -0,0 +1,133 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import jakarta.persistence.AssociationOverride;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AssociationOverrideJpaAnnotation implements AssociationOverride {
private String name;
private jakarta.persistence.JoinColumn[] joinColumns;
private jakarta.persistence.ForeignKey foreignKey;
private jakarta.persistence.JoinTable joinTable;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AssociationOverrideJpaAnnotation(SourceModelBuildingContext modelContext) {
this.joinColumns = new jakarta.persistence.JoinColumn[0];
this.foreignKey = modelContext.getAnnotationDescriptorRegistry()
.getDescriptor( jakarta.persistence.ForeignKey.class )
.createUsage( modelContext );
this.joinTable = modelContext.getAnnotationDescriptorRegistry()
.getDescriptor( jakarta.persistence.JoinTable.class )
.createUsage( modelContext );
}
/**
* Used in creating annotation instances from JDK variant
*/
public AssociationOverrideJpaAnnotation(AssociationOverride annotation, SourceModelBuildingContext modelContext) {
this.name = extractJdkValue( annotation, JpaAnnotations.ASSOCIATION_OVERRIDE, "name", modelContext );
this.joinColumns = extractJdkValue(
annotation,
JpaAnnotations.ASSOCIATION_OVERRIDE,
"joinColumns",
modelContext
);
this.foreignKey = extractJdkValue(
annotation,
JpaAnnotations.ASSOCIATION_OVERRIDE,
"foreignKey",
modelContext
);
this.joinTable = extractJdkValue( annotation, JpaAnnotations.ASSOCIATION_OVERRIDE, "joinTable", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AssociationOverrideJpaAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.name = extractJandexValue( annotation, JpaAnnotations.ASSOCIATION_OVERRIDE, "name", modelContext );
this.joinColumns = extractJandexValue(
annotation,
JpaAnnotations.ASSOCIATION_OVERRIDE,
"joinColumns",
modelContext
);
this.foreignKey = extractJandexValue(
annotation,
JpaAnnotations.ASSOCIATION_OVERRIDE,
"foreignKey",
modelContext
);
this.joinTable = extractJandexValue(
annotation,
JpaAnnotations.ASSOCIATION_OVERRIDE,
"joinTable",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AssociationOverride.class;
}
@Override
public String name() {
return name;
}
public void name(String value) {
this.name = value;
}
@Override
public jakarta.persistence.JoinColumn[] joinColumns() {
return joinColumns;
}
public void joinColumns(jakarta.persistence.JoinColumn[] value) {
this.joinColumns = value;
}
@Override
public jakarta.persistence.ForeignKey foreignKey() {
return foreignKey;
}
public void foreignKey(jakarta.persistence.ForeignKey value) {
this.foreignKey = value;
}
@Override
public jakarta.persistence.JoinTable joinTable() {
return joinTable;
}
public void joinTable(jakarta.persistence.JoinTable value) {
this.joinTable = value;
}
}

View File

@ -0,0 +1,61 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import jakarta.persistence.AssociationOverrides;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AssociationOverridesJpaAnnotation implements AssociationOverrides {
private jakarta.persistence.AssociationOverride[] value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AssociationOverridesJpaAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AssociationOverridesJpaAnnotation(AssociationOverrides annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue( annotation, JpaAnnotations.ASSOCIATION_OVERRIDES, "value", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AssociationOverridesJpaAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, JpaAnnotations.ASSOCIATION_OVERRIDES, "value", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return AssociationOverrides.class;
}
@Override
public jakarta.persistence.AssociationOverride[] value() {
return value;
}
public void value(jakarta.persistence.AssociationOverride[] value) {
this.value = value;
}
}

View File

@ -0,0 +1,85 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AttributeAccessor;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AttributeAccessorAnnotation implements AttributeAccessor {
private String value;
private java.lang.Class<? extends org.hibernate.property.access.spi.PropertyAccessStrategy> strategy;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AttributeAccessorAnnotation(SourceModelBuildingContext modelContext) {
this.value = "";
this.strategy = org.hibernate.property.access.spi.PropertyAccessStrategy.class;
}
/**
* Used in creating annotation instances from JDK variant
*/
public AttributeAccessorAnnotation(AttributeAccessor annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue( annotation, HibernateAnnotations.ATTRIBUTE_ACCESSOR, "value", modelContext );
this.strategy = extractJdkValue(
annotation,
HibernateAnnotations.ATTRIBUTE_ACCESSOR,
"strategy",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AttributeAccessorAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, HibernateAnnotations.ATTRIBUTE_ACCESSOR, "value", modelContext );
this.strategy = extractJandexValue(
annotation,
HibernateAnnotations.ATTRIBUTE_ACCESSOR,
"strategy",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AttributeAccessor.class;
}
@Override
public String value() {
return value;
}
public void value(String value) {
this.value = value;
}
@Override
public java.lang.Class<? extends org.hibernate.property.access.spi.PropertyAccessStrategy> strategy() {
return strategy;
}
public void strategy(java.lang.Class<? extends org.hibernate.property.access.spi.PropertyAccessStrategy> value) {
this.strategy = value;
}
}

View File

@ -0,0 +1,70 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.AttributeBinderType;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AttributeBinderTypeAnnotation implements AttributeBinderType {
private java.lang.Class<? extends org.hibernate.binder.AttributeBinder<?>> binder;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AttributeBinderTypeAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AttributeBinderTypeAnnotation(AttributeBinderType annotation, SourceModelBuildingContext modelContext) {
this.binder = extractJdkValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ATTRIBUTE_BINDER_TYPE,
"binder",
modelContext
);
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AttributeBinderTypeAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.binder = extractJandexValue(
annotation,
org.hibernate.boot.models.HibernateAnnotations.ATTRIBUTE_BINDER_TYPE,
"binder",
modelContext
);
}
@Override
public Class<? extends Annotation> annotationType() {
return AttributeBinderType.class;
}
@Override
public java.lang.Class<? extends org.hibernate.binder.AttributeBinder<?>> binder() {
return binder;
}
public void binder(java.lang.Class<? extends org.hibernate.binder.AttributeBinder<?>> value) {
this.binder = value;
}
}

View File

@ -0,0 +1,75 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import jakarta.persistence.AttributeOverride;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AttributeOverrideJpaAnnotation implements AttributeOverride {
private String name;
private jakarta.persistence.Column column;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AttributeOverrideJpaAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AttributeOverrideJpaAnnotation(AttributeOverride annotation, SourceModelBuildingContext modelContext) {
this.name = extractJdkValue( annotation, JpaAnnotations.ATTRIBUTE_OVERRIDE, "name", modelContext );
this.column = extractJdkValue( annotation, JpaAnnotations.ATTRIBUTE_OVERRIDE, "column", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AttributeOverrideJpaAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.name = extractJandexValue( annotation, JpaAnnotations.ATTRIBUTE_OVERRIDE, "name", modelContext );
this.column = extractJandexValue( annotation, JpaAnnotations.ATTRIBUTE_OVERRIDE, "column", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return AttributeOverride.class;
}
@Override
public String name() {
return name;
}
public void name(String value) {
this.name = value;
}
@Override
public jakarta.persistence.Column column() {
return column;
}
public void column(jakarta.persistence.Column value) {
this.column = value;
}
}

View File

@ -0,0 +1,61 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import jakarta.persistence.AttributeOverrides;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class AttributeOverridesJpaAnnotation implements AttributeOverrides {
private jakarta.persistence.AttributeOverride[] value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public AttributeOverridesJpaAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public AttributeOverridesJpaAnnotation(AttributeOverrides annotation, SourceModelBuildingContext modelContext) {
this.value = extractJdkValue( annotation, JpaAnnotations.ATTRIBUTE_OVERRIDES, "value", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public AttributeOverridesJpaAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, JpaAnnotations.ATTRIBUTE_OVERRIDES, "value", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return AttributeOverrides.class;
}
@Override
public jakarta.persistence.AttributeOverride[] value() {
return value;
}
public void value(jakarta.persistence.AttributeOverride[] value) {
this.value = value;
}
}

View File

@ -0,0 +1,42 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.Bag;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class BagAnnotation implements Bag {
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public BagAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public BagAnnotation(Bag annotation, SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from Jandex variant
*/
public BagAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
}
@Override
public Class<? extends Annotation> annotationType() {
return Bag.class;
}
}

View File

@ -0,0 +1,79 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.annotations.spi.AttributeMarker;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import jakarta.persistence.Basic;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class BasicJpaAnnotation
implements Basic, AttributeMarker, AttributeMarker.Fetchable, AttributeMarker.Optionalable {
private jakarta.persistence.FetchType fetch;
private boolean optional;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public BasicJpaAnnotation(SourceModelBuildingContext modelContext) {
this.fetch = jakarta.persistence.FetchType.EAGER;
this.optional = true;
}
/**
* Used in creating annotation instances from JDK variant
*/
public BasicJpaAnnotation(Basic annotation, SourceModelBuildingContext modelContext) {
this.fetch = extractJdkValue( annotation, JpaAnnotations.BASIC, "fetch", modelContext );
this.optional = extractJdkValue( annotation, JpaAnnotations.BASIC, "optional", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public BasicJpaAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.fetch = extractJandexValue( annotation, JpaAnnotations.BASIC, "fetch", modelContext );
this.optional = extractJandexValue( annotation, JpaAnnotations.BASIC, "optional", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return Basic.class;
}
@Override
public jakarta.persistence.FetchType fetch() {
return fetch;
}
public void fetch(jakarta.persistence.FetchType value) {
this.fetch = value;
}
@Override
public boolean optional() {
return optional;
}
public void optional(boolean value) {
this.optional = value;
}
}

View File

@ -0,0 +1,60 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.BatchSize;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class BatchSizeAnnotation implements BatchSize {
private int size;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public BatchSizeAnnotation(SourceModelBuildingContext modelContext) {
}
/**
* Used in creating annotation instances from JDK variant
*/
public BatchSizeAnnotation(BatchSize annotation, SourceModelBuildingContext modelContext) {
this.size = extractJdkValue( annotation, HibernateAnnotations.BATCH_SIZE, "size", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public BatchSizeAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.size = extractJandexValue( annotation, HibernateAnnotations.BATCH_SIZE, "size", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return BatchSize.class;
}
@Override
public int size() {
return size;
}
public void size(int value) {
this.size = value;
}
}

View File

@ -0,0 +1,102 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.Cache;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJdkValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class CacheAnnotation implements Cache {
private org.hibernate.annotations.CacheConcurrencyStrategy usage;
private String region;
private boolean includeLazy;
private String include;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public CacheAnnotation(SourceModelBuildingContext modelContext) {
this.region = "";
this.includeLazy = true;
this.include = "all";
}
/**
* Used in creating annotation instances from JDK variant
*/
public CacheAnnotation(Cache annotation, SourceModelBuildingContext modelContext) {
this.usage = extractJdkValue( annotation, HibernateAnnotations.CACHE, "usage", modelContext );
this.region = extractJdkValue( annotation, HibernateAnnotations.CACHE, "region", modelContext );
this.includeLazy = extractJdkValue( annotation, HibernateAnnotations.CACHE, "includeLazy", modelContext );
this.include = extractJdkValue( annotation, HibernateAnnotations.CACHE, "include", modelContext );
}
/**
* Used in creating annotation instances from Jandex variant
*/
public CacheAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.usage = extractJandexValue( annotation, HibernateAnnotations.CACHE, "usage", modelContext );
this.region = extractJandexValue( annotation, HibernateAnnotations.CACHE, "region", modelContext );
this.includeLazy = extractJandexValue( annotation, HibernateAnnotations.CACHE, "includeLazy", modelContext );
this.include = extractJandexValue( annotation, HibernateAnnotations.CACHE, "include", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return Cache.class;
}
@Override
public org.hibernate.annotations.CacheConcurrencyStrategy usage() {
return usage;
}
public void usage(org.hibernate.annotations.CacheConcurrencyStrategy value) {
this.usage = value;
}
@Override
public String region() {
return region;
}
public void region(String value) {
this.region = value;
}
@Override
public boolean includeLazy() {
return includeLazy;
}
public void includeLazy(boolean value) {
this.includeLazy = value;
}
@Override
public String include() {
return include;
}
public void include(String value) {
this.include = value;
}
}

Some files were not shown because too many files have changed in this diff Show More