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. * 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. * 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; package org.hibernate.orm.build.annotations.structure;
import org.hibernate.boot.model.naming.Identifier;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface PhysicalTableReference extends PersistentTableReference { public class BooleanType implements Type {
Identifier getPhysicalTableName(); 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 libs.jacksonXml
compileOnly dbLibs.postgresql compileOnly dbLibs.postgresql
// annotationProcessor project( ":annotation-descriptor-generator" )
compileOnly project( ":annotation-descriptor-generator" )
testImplementation project(':hibernate-testing') testImplementation project(':hibernate-testing')
testImplementation project(':hibernate-ant') testImplementation project(':hibernate-ant')
testImplementation testLibs.shrinkwrapApi testImplementation testLibs.shrinkwrapApi
@ -206,6 +209,22 @@ artifacts {
tests testJar 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( task generateEnversStaticMetamodel(
type: JavaCompile, type: JavaCompile,
description: "Generate the Hibernate Envers revision entity static metamodel classes." ) { 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.PACKAGE;
import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.TYPE_PARAMETER; import static java.lang.annotation.ElementType.TYPE_PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
/** /**
@ -32,7 +31,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@Target({METHOD, FIELD, TYPE, PACKAGE, CONSTRUCTOR, TYPE_PARAMETER, TYPE_USE}) @Target({METHOD, FIELD, TYPE, PACKAGE, CONSTRUCTOR, TYPE_PARAMETER})
@Retention(RUNTIME) @Retention(RUNTIME)
@Documented @Documented
public @interface Remove { public @interface Remove {

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.boot.internal; package org.hibernate.boot.internal;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.hibernate.boot.model.IdentifierGeneratorDefinition; import org.hibernate.boot.model.IdentifierGeneratorDefinition;
@ -18,7 +17,6 @@ import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType; import jakarta.persistence.GenerationType;
@ -86,28 +84,28 @@ public class GenerationStrategyInterpreter {
} }
public void interpretTableGenerator( public void interpretTableGenerator(
AnnotationUsage<TableGenerator> tableGeneratorAnnotation, TableGenerator tableGeneratorAnnotation,
IdentifierGeneratorDefinition.Builder definitionBuilder) { IdentifierGeneratorDefinition.Builder definitionBuilder) {
definitionBuilder.setName( tableGeneratorAnnotation.getString( "name" ) ); definitionBuilder.setName( tableGeneratorAnnotation.name() );
definitionBuilder.setStrategy( org.hibernate.id.enhanced.TableGenerator.class.getName() ); definitionBuilder.setStrategy( org.hibernate.id.enhanced.TableGenerator.class.getName() );
definitionBuilder.addParam( org.hibernate.id.enhanced.TableGenerator.CONFIG_PREFER_SEGMENT_PER_ENTITY, "true" ); 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 ) ) { if ( StringHelper.isNotEmpty( catalog ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, catalog ); definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, catalog );
} }
final String schema = tableGeneratorAnnotation.getString( "schema" ); final String schema = tableGeneratorAnnotation.schema();
if ( StringHelper.isNotEmpty( schema ) ) { if ( StringHelper.isNotEmpty( schema ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, schema ); definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, schema );
} }
final String table = tableGeneratorAnnotation.getString( "table" ); final String table = tableGeneratorAnnotation.table();
if ( StringHelper.isNotEmpty( table ) ) { if ( StringHelper.isNotEmpty( table ) ) {
definitionBuilder.addParam( org.hibernate.id.enhanced.TableGenerator.TABLE_PARAM, 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 ) ) { if ( StringHelper.isNotEmpty( pkColumnName ) ) {
definitionBuilder.addParam( definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.SEGMENT_COLUMN_PARAM, 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 ) ) { if ( StringHelper.isNotEmpty( pkColumnValue ) ) {
definitionBuilder.addParam( definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.SEGMENT_VALUE_PARAM, 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 ) ) { if ( StringHelper.isNotEmpty( valueColumnName ) ) {
definitionBuilder.addParam( definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.VALUE_COLUMN_PARAM, 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 ) ) { if ( StringHelper.isNotEmpty( options ) ) {
definitionBuilder.addParam( definitionBuilder.addParam(
PersistentIdentifierGenerator.OPTIONS, PersistentIdentifierGenerator.OPTIONS,
@ -141,53 +139,53 @@ public class GenerationStrategyInterpreter {
definitionBuilder.addParam( definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.INCREMENT_PARAM, 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 // See comment on HHH-4884 wrt initialValue. Basically initialValue is really the stated value + 1
definitionBuilder.addParam( definitionBuilder.addParam(
org.hibernate.id.enhanced.TableGenerator.INITIAL_PARAM, org.hibernate.id.enhanced.TableGenerator.INITIAL_PARAM,
String.valueOf( tableGeneratorAnnotation.getInteger( "initialValue" ) + 1 ) String.valueOf( tableGeneratorAnnotation.initialValue() + 1 )
); );
// TODO : implement unique-constraint support // TODO : implement unique-constraint support
final List<AnnotationUsage<UniqueConstraint>> uniqueConstraints = tableGeneratorAnnotation.getList( "uniqueConstraints" ); final UniqueConstraint[] uniqueConstraints = tableGeneratorAnnotation.uniqueConstraints();
if ( CollectionHelper.isNotEmpty( uniqueConstraints ) ) { if ( CollectionHelper.isNotEmpty( uniqueConstraints ) ) {
LOG.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.getString( "name" ) ); LOG.ignoringTableGeneratorConstraints( tableGeneratorAnnotation.name() );
} }
} }
public void interpretSequenceGenerator( public void interpretSequenceGenerator(
AnnotationUsage<SequenceGenerator> sequenceGeneratorAnnotation, SequenceGenerator sequenceGeneratorAnnotation,
IdentifierGeneratorDefinition.Builder definitionBuilder) { IdentifierGeneratorDefinition.Builder definitionBuilder) {
definitionBuilder.setName( sequenceGeneratorAnnotation.getString( "name" ) ); definitionBuilder.setName( sequenceGeneratorAnnotation.name() );
definitionBuilder.setStrategy( SequenceStyleGenerator.class.getName() ); definitionBuilder.setStrategy( SequenceStyleGenerator.class.getName() );
final String catalog = sequenceGeneratorAnnotation.getString( "catalog" ); final String catalog = sequenceGeneratorAnnotation.catalog();
if ( StringHelper.isNotEmpty( catalog ) ) { if ( StringHelper.isNotEmpty( catalog ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, catalog ); definitionBuilder.addParam( PersistentIdentifierGenerator.CATALOG, catalog );
} }
final String schema = sequenceGeneratorAnnotation.getString( "schema" ); final String schema = sequenceGeneratorAnnotation.schema();
if ( StringHelper.isNotEmpty( schema ) ) { if ( StringHelper.isNotEmpty( schema ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, schema ); definitionBuilder.addParam( PersistentIdentifierGenerator.SCHEMA, schema );
} }
final String sequenceName = sequenceGeneratorAnnotation.getString( "sequenceName" ); final String sequenceName = sequenceGeneratorAnnotation.sequenceName();
if ( StringHelper.isNotEmpty( sequenceName ) ) { if ( StringHelper.isNotEmpty( sequenceName ) ) {
definitionBuilder.addParam( SequenceStyleGenerator.SEQUENCE_PARAM, sequenceName ); definitionBuilder.addParam( SequenceStyleGenerator.SEQUENCE_PARAM, sequenceName );
} }
definitionBuilder.addParam( definitionBuilder.addParam(
SequenceStyleGenerator.INCREMENT_PARAM, SequenceStyleGenerator.INCREMENT_PARAM,
String.valueOf( sequenceGeneratorAnnotation.getInteger( "allocationSize" ) ) String.valueOf( sequenceGeneratorAnnotation.allocationSize() )
); );
definitionBuilder.addParam( definitionBuilder.addParam(
SequenceStyleGenerator.INITIAL_PARAM, 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 ) ) { if ( StringHelper.isNotEmpty( options ) ) {
definitionBuilder.addParam( PersistentIdentifierGenerator.OPTIONS, 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.internal.ImplicitColumnNamingSecondPass;
import org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext; import org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext;
import org.hibernate.boot.models.categorize.internal.ClassLoaderServiceLoading; import org.hibernate.boot.models.categorize.internal.ClassLoaderServiceLoading;
import org.hibernate.boot.models.categorize.internal.GlobalRegistrationsImpl; import org.hibernate.boot.models.internal.GlobalRegistrationsImpl;
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations; import org.hibernate.boot.models.internal.ModelsHelper;
import org.hibernate.boot.models.categorize.spi.ManagedResourcesProcessor; import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.models.xml.internal.PersistenceUnitMetadataImpl; import org.hibernate.boot.models.xml.internal.PersistenceUnitMetadataImpl;
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata; import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.boot.query.NamedHqlQueryDefinition; 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.mapping.DiscriminatorType;
import org.hibernate.metamodel.spi.EmbeddableInstantiator; import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.models.internal.SourceModelBuildingContextImpl; import org.hibernate.models.internal.SourceModelBuildingContextImpl;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.SourceModelBuildingContext; import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.query.named.NamedObjectRepository; import org.hibernate.query.named.NamedObjectRepository;
@ -233,7 +232,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
return new SourceModelBuildingContextImpl( return new SourceModelBuildingContextImpl(
classLoading, classLoading,
bootstrapContext.getJandexView(), bootstrapContext.getJandexView(),
ManagedResourcesProcessor::preFillRegistries ModelsHelper::preFillRegistries
); );
} }
@ -548,9 +547,9 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
private Map<CollectionClassification, CollectionTypeRegistrationDescriptor> collectionTypeRegistrations; private Map<CollectionClassification, CollectionTypeRegistrationDescriptor> collectionTypeRegistrations;
@Override @Override
public void addCollectionTypeRegistration(AnnotationUsage<CollectionTypeRegistration> registrationAnnotation) { public void addCollectionTypeRegistration(CollectionTypeRegistration registrationAnnotation) {
addCollectionTypeRegistration( addCollectionTypeRegistration(
registrationAnnotation.getEnum( "classification" ), registrationAnnotation.classification(),
toDescriptor( registrationAnnotation ) toDescriptor( registrationAnnotation )
); );
} }
@ -572,21 +571,21 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
return collectionTypeRegistrations.get( classification ); return collectionTypeRegistrations.get( classification );
} }
private CollectionTypeRegistrationDescriptor toDescriptor(AnnotationUsage<CollectionTypeRegistration> registrationAnnotation) { private CollectionTypeRegistrationDescriptor toDescriptor(CollectionTypeRegistration registrationAnnotation) {
return new CollectionTypeRegistrationDescriptor( return new CollectionTypeRegistrationDescriptor(
registrationAnnotation.getClassDetails( "type" ).toJavaClass(), registrationAnnotation.type(),
extractParameters( registrationAnnotation.getList( "parameters" ) ) extractParameters( registrationAnnotation.parameters() )
); );
} }
private Map<String,String> extractParameters(List<AnnotationUsage<Parameter>> annotationUsages) { private Map<String,String> extractParameters(Parameter[] annotationUsages) {
if ( CollectionHelper.isEmpty( annotationUsages ) ) { if ( CollectionHelper.isEmpty( annotationUsages ) ) {
return null; return null;
} }
final Map<String,String> result = mapOfSize( annotationUsages.size() ); final Map<String,String> result = mapOfSize( annotationUsages.length );
for ( AnnotationUsage<Parameter> parameter : annotationUsages ) { for ( Parameter parameter : annotationUsages ) {
result.put( parameter.getString( "name" ), parameter.getString( "value" ) ); result.put( parameter.name(), parameter.value() );
} }
return result; return result;
} }
@ -1369,16 +1368,16 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
} }
private static AnnotatedClassType getAnnotatedClassType2(ClassDetails classDetails) { private static AnnotatedClassType getAnnotatedClassType2(ClassDetails classDetails) {
if ( classDetails.hasAnnotationUsage( Entity.class ) ) { if ( classDetails.hasDirectAnnotationUsage( Entity.class ) ) {
return AnnotatedClassType.ENTITY; return AnnotatedClassType.ENTITY;
} }
else if ( classDetails.hasAnnotationUsage( Embeddable.class ) ) { else if ( classDetails.hasDirectAnnotationUsage( Embeddable.class ) ) {
return AnnotatedClassType.EMBEDDABLE; return AnnotatedClassType.EMBEDDABLE;
} }
else if ( classDetails.hasAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) { else if ( classDetails.hasDirectAnnotationUsage( jakarta.persistence.MappedSuperclass.class ) ) {
return AnnotatedClassType.MAPPED_SUPERCLASS; return AnnotatedClassType.MAPPED_SUPERCLASS;
} }
else if ( classDetails.hasAnnotationUsage( Imported.class ) ) { else if ( classDetails.hasDirectAnnotationUsage( Imported.class ) ) {
return AnnotatedClassType.IMPORTED; return AnnotatedClassType.IMPORTED;
} }
else { else {
@ -1435,7 +1434,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector,
k -> new HashMap<>() k -> new HashMap<>()
); );
map.put( map.put(
property.getAttributeMember().getAnnotationUsage( MapsId.class ).getString( "value" ), property.getAttributeMember().getDirectAnnotationUsage( MapsId.class ).value(),
property property
); );
} }

View File

@ -20,8 +20,6 @@ import org.hibernate.boot.query.NamedProcedureCallDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper; 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.NamedCallableQueryMementoImpl;
import org.hibernate.procedure.internal.Util; import org.hibernate.procedure.internal.Util;
import org.hibernate.procedure.spi.NamedCallableQueryMemento; import org.hibernate.procedure.spi.NamedCallableQueryMemento;
@ -50,15 +48,15 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private final ParameterDefinitions parameterDefinitions; private final ParameterDefinitions parameterDefinitions;
private final Map<String, Object> hints; private final Map<String, Object> hints;
public NamedProcedureCallDefinitionImpl(AnnotationUsage<NamedStoredProcedureQuery> annotation) { public NamedProcedureCallDefinitionImpl(NamedStoredProcedureQuery annotation) {
this.registeredName = annotation.getString( "name" ); this.registeredName = annotation.name();
this.procedureName = annotation.getString( "procedureName" ); this.procedureName = annotation.procedureName();
this.hints = new QueryHintDefinition( registeredName, annotation.getList( "hints" ) ).getHintsMap(); this.hints = new QueryHintDefinition( registeredName, annotation.hints() ).getHintsMap();
this.resultClasses = interpretResultClasses( annotation ); this.resultClasses = annotation.resultClasses();
this.resultSetMappings = interpretResultMappings( annotation ); 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 specifiesResultClasses = resultClasses != null && resultClasses.length > 0;
final boolean specifiesResultSetMappings = resultSetMappings != null && resultSetMappings.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 @Override
public String getRegistrationName() { public String getRegistrationName() {
return registeredName; return registeredName;
@ -164,22 +138,22 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private final ParameterStrategy parameterStrategy; private final ParameterStrategy parameterStrategy;
private final ParameterDefinition<?>[] parameterDefinitions; private final ParameterDefinition<?>[] parameterDefinitions;
ParameterDefinitions(List<AnnotationUsage<StoredProcedureParameter>> parameters) { ParameterDefinitions(StoredProcedureParameter[] parameters) {
if ( CollectionHelper.isEmpty( parameters ) ) { if ( CollectionHelper.isEmpty( parameters ) ) {
parameterStrategy = ParameterStrategy.POSITIONAL; parameterStrategy = ParameterStrategy.POSITIONAL;
parameterDefinitions = new ParameterDefinition[0]; parameterDefinitions = new ParameterDefinition[0];
} }
else { else {
final AnnotationUsage<StoredProcedureParameter> parameterAnn = parameters.get( 0 ); final StoredProcedureParameter parameterAnn = parameters[0];
final boolean firstParameterHasName = StringHelper.isNotEmpty( parameterAnn.findAttributeValue( "name" ) ); final boolean firstParameterHasName = StringHelper.isNotEmpty( parameterAnn.name() );
parameterStrategy = firstParameterHasName parameterStrategy = firstParameterHasName
? ParameterStrategy.NAMED ? ParameterStrategy.NAMED
: ParameterStrategy.POSITIONAL; : 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 // 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 ParameterMode parameterMode;
private final Class<T> type; private final Class<T> type;
ParameterDefinition(int position, AnnotationUsage<StoredProcedureParameter> annotation) { ParameterDefinition(int position, StoredProcedureParameter annotation) {
this.position = position; this.position = position;
this.name = normalize( annotation.getString( "name" ) ); this.name = normalize( annotation.name() );
this.parameterMode = annotation.getEnum( "mode" ); this.parameterMode = annotation.mode();
this.type = annotation.getClassDetails( "type" ).toJavaClass(); //noinspection unchecked
this.type = (Class<T>) annotation.type();
} }
public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) { public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@ import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.boot.spi.PropertyData; import org.hibernate.boot.spi.PropertyData;
import org.hibernate.cfg.RecoverableException; import org.hibernate.cfg.RecoverableException;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; 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.Column;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
@ -39,7 +39,6 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.Selectable; import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
@ -77,7 +76,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
private String manyToManyOwnerSideEntityName; private String manyToManyOwnerSideEntityName;
public static AnnotatedJoinColumns buildJoinColumnsOrFormulas( public static AnnotatedJoinColumns buildJoinColumnsOrFormulas(
List<AnnotationUsage<JoinColumnOrFormula>> joinColumnOrFormulas, JoinColumnOrFormula[] joinColumnOrFormulas,
String mappedBy, String mappedBy,
Map<String, Join> joins, Map<String, Join> joins,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
@ -89,10 +88,10 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
parent.setPropertyHolder( propertyHolder ); parent.setPropertyHolder( propertyHolder );
parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) ); parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
parent.setMappedBy( mappedBy ); parent.setMappedBy( mappedBy );
for ( AnnotationUsage<JoinColumnOrFormula> columnOrFormula : joinColumnOrFormulas ) { for ( JoinColumnOrFormula columnOrFormula : joinColumnOrFormulas ) {
final AnnotationUsage<JoinFormula> formula = columnOrFormula.getNestedUsage( "formula" ); final JoinFormula formula = columnOrFormula.formula();
final AnnotationUsage<JoinColumn> column = columnOrFormula.getNestedUsage( "column" ); final JoinColumn column = columnOrFormula.column();
final String annotationString = formula.getString( "value" ); final String annotationString = formula.value();
if ( isNotEmpty( annotationString ) ) { if ( isNotEmpty( annotationString ) ) {
AnnotatedJoinColumn.buildJoinFormula( formula, parent ); AnnotatedJoinColumn.buildJoinFormula( formula, parent );
} }
@ -104,7 +103,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
} }
static AnnotatedJoinColumns buildJoinColumnsWithFormula( static AnnotatedJoinColumns buildJoinColumnsWithFormula(
AnnotationUsage<JoinFormula> joinFormula, JoinFormula joinFormula,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
@ -119,7 +118,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
} }
public static AnnotatedJoinColumns buildJoinColumns( public static AnnotatedJoinColumns buildJoinColumns(
List<AnnotationUsage<JoinColumn>> joinColumns, JoinColumn[] joinColumns,
// Comment comment, // Comment comment,
String mappedBy, String mappedBy,
Map<String, Join> joins, Map<String, Join> joins,
@ -139,7 +138,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
} }
public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix( public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
List<AnnotationUsage<JoinColumn>> joinColumns, JoinColumn[] joinColumns,
// Comment comment, // Comment comment,
String mappedBy, String mappedBy,
Map<String, Join> joins, Map<String, Join> joins,
@ -150,15 +149,15 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
assert mappedBy == null || !mappedBy.isEmpty(); assert mappedBy == null || !mappedBy.isEmpty();
final String propertyName = inferredData.getPropertyName(); final String propertyName = inferredData.getPropertyName();
final String path = qualify( propertyHolder.getPath(), propertyName ); final String path = qualify( propertyHolder.getPath(), propertyName );
final List<AnnotationUsage<JoinColumn>> overrides = propertyHolder.getOverriddenJoinColumn( path ); final JoinColumn[] overrides = propertyHolder.getOverriddenJoinColumn( path );
final List<AnnotationUsage<JoinColumn>> actualColumns = overrides == null ? joinColumns : overrides; final JoinColumn[] actualColumns = overrides == null ? joinColumns : overrides;
final AnnotatedJoinColumns parent = new AnnotatedJoinColumns(); final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
parent.setBuildingContext( context ); parent.setBuildingContext( context );
parent.setJoins( joins ); parent.setJoins( joins );
parent.setPropertyHolder( propertyHolder ); parent.setPropertyHolder( propertyHolder );
parent.setPropertyName( getRelativePath( propertyHolder, propertyName ) ); parent.setPropertyName( getRelativePath( propertyHolder, propertyName ) );
parent.setMappedBy( mappedBy ); parent.setMappedBy( mappedBy );
if ( CollectionHelper.isEmpty( actualColumns ) ) { if ( ArrayHelper.isEmpty( actualColumns ) ) {
AnnotatedJoinColumn.buildJoinColumn( AnnotatedJoinColumn.buildJoinColumn(
null, null,
// comment, // comment,
@ -171,7 +170,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
} }
else { else {
parent.setMappedBy( mappedBy ); parent.setMappedBy( mappedBy );
for ( AnnotationUsage<JoinColumn> actualColumn : actualColumns ) { for ( JoinColumn actualColumn : actualColumns ) {
AnnotatedJoinColumn.buildJoinColumn( AnnotatedJoinColumn.buildJoinColumn(
actualColumn, actualColumn,
// comment, // comment,
@ -190,7 +189,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
* Called for join tables in {@link jakarta.persistence.ManyToMany} associations. * Called for join tables in {@link jakarta.persistence.ManyToMany} associations.
*/ */
public static AnnotatedJoinColumns buildJoinTableJoinColumns( public static AnnotatedJoinColumns buildJoinTableJoinColumns(
List<AnnotationUsage<JoinColumn>> joinColumns, JoinColumn[] joinColumns,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
@ -206,7 +205,7 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
AnnotatedJoinColumn.buildImplicitJoinTableJoinColumn( parent, propertyHolder, inferredData ); AnnotatedJoinColumn.buildImplicitJoinTableJoinColumn( parent, propertyHolder, inferredData );
} }
else { else {
for ( AnnotationUsage<JoinColumn> joinColumn : joinColumns ) { for ( JoinColumn joinColumn : joinColumns ) {
AnnotatedJoinColumn.buildExplicitJoinTableJoinColumn( parent, propertyHolder, inferredData, joinColumn ); 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.internal.GenerationStrategyInterpreter;
import org.hibernate.boot.model.IdentifierGeneratorDefinition; import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.model.convert.spi.RegisteredConversion; 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.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.models.spi.AnnotationTarget; import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer; import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.type.descriptor.java.BasicJavaType; import org.hibernate.type.descriptor.java.BasicJavaType;
@ -45,11 +46,7 @@ import jakarta.persistence.FetchType;
import jakarta.persistence.Inheritance; import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType; import jakarta.persistence.InheritanceType;
import jakarta.persistence.MappedSuperclass; import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.NamedNativeQuery;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NamedStoredProcedureQuery;
import jakarta.persistence.SequenceGenerator; import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.SqlResultSetMapping;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.persistence.TableGenerator; 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.FilterDefBinder.bindFilterDefs;
import static org.hibernate.boot.model.internal.GeneratorBinder.buildGenerators; 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.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.getInheritanceStateOfSuperEntity;
import static org.hibernate.boot.model.internal.InheritanceState.getSuperclassInheritanceState; import static org.hibernate.boot.model.internal.InheritanceState.getSuperclassInheritanceState;
import static org.hibernate.internal.CoreLogging.messageLogger; import static org.hibernate.internal.CoreLogging.messageLogger;
@ -157,16 +152,18 @@ public final class AnnotationBinder {
} }
private static void handleIdGenerators(ClassDetails packageInfoClassDetails, MetadataBuildingContext context) { private static void handleIdGenerators(ClassDetails packageInfoClassDetails, MetadataBuildingContext context) {
packageInfoClassDetails.forEachAnnotationUsage( SequenceGenerator.class, usage -> { final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
IdentifierGeneratorDefinition idGen = buildSequenceIdGenerator( usage );
packageInfoClassDetails.forEachAnnotationUsage( SequenceGenerator.class, sourceModelContext, (usage) -> {
IdentifierGeneratorDefinition idGen = buildIdGenerator( usage, context );
context.getMetadataCollector().addIdentifierGenerator( idGen ); context.getMetadataCollector().addIdentifierGenerator( idGen );
if ( LOG.isTraceEnabled() ) { if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() ); LOG.tracev( "Add sequence generator with name: {0}", idGen.getName() );
} }
} ); } );
packageInfoClassDetails.forEachAnnotationUsage( TableGenerator.class, usage -> { packageInfoClassDetails.forEachAnnotationUsage( TableGenerator.class, sourceModelContext, (usage) -> {
IdentifierGeneratorDefinition idGen = buildTableIdGenerator( usage ); IdentifierGeneratorDefinition idGen = buildIdGenerator( usage, context );
context.getMetadataCollector().addIdentifierGenerator( idGen ); context.getMetadataCollector().addIdentifierGenerator( idGen );
if ( LOG.isTraceEnabled() ) { if ( LOG.isTraceEnabled() ) {
LOG.tracev( "Add table generator with name: {0}", idGen.getName() ); 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) { 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 ); bindGenericGenerator( usage, context );
} ); } );
} }
private static void bindGenericGenerator(AnnotationUsage<GenericGenerator> def, MetadataBuildingContext context) { private static void bindGenericGenerator(GenericGenerator def, MetadataBuildingContext context) {
context.getMetadataCollector().addIdentifierGenerator( buildIdGenerator( def ) ); context.getMetadataCollector().addIdentifierGenerator( buildIdGenerator( def, context ) );
} }
public static void bindQueries(AnnotationTarget annotationTarget, MetadataBuildingContext 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) { private static void bindNamedHibernateQueries(AnnotationTarget annotationTarget, MetadataBuildingContext context) {
annotationTarget.forEachAnnotationUsage( org.hibernate.annotations.NamedQuery.class, (usage) -> QueryBinder.bindQuery( final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
usage,
context
) );
annotationTarget.forEachAnnotationUsage( org.hibernate.annotations.NamedNativeQuery.class, (usage) -> QueryBinder.bindNativeQuery( annotationTarget.forEachRepeatedAnnotationUsages(
usage, HibernateAnnotations.NAMED_QUERY,
context 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) { private static void bindNamedJpaQueries(AnnotationTarget annotationTarget, MetadataBuildingContext context) {
annotationTarget.forEachAnnotationUsage( SqlResultSetMapping.class, (usage) -> QueryBinder.bindSqlResultSetMapping( final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
usage,
context,
false
) );
annotationTarget.forEachAnnotationUsage( NamedQuery.class, (usage) -> QueryBinder.bindQuery( annotationTarget.forEachRepeatedAnnotationUsages(
usage, JpaAnnotations.SQL_RESULT_SET_MAPPING,
context, sourceModelContext,
false (usage) -> QueryBinder.bindSqlResultSetMapping( usage, context,false )
) ); );
annotationTarget.forEachAnnotationUsage( NamedNativeQuery.class, (usage) -> QueryBinder.bindNativeQuery( annotationTarget.forEachRepeatedAnnotationUsages(
usage, JpaAnnotations.NAMED_QUERY,
context, sourceModelContext,
false (usage) -> QueryBinder.bindQuery( usage, context, false )
) ); );
annotationTarget.forEachAnnotationUsage( NamedStoredProcedureQuery.class, (usage) -> QueryBinder.bindNamedStoredProcedureQuery( annotationTarget.forEachRepeatedAnnotationUsages(
usage, JpaAnnotations.NAMED_NATIVE_QUERY,
context, sourceModelContext,
false (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) { 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 qualifiedName = annotatedClass.getName();
final String name = unqualify( qualifiedName ); 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 ); context.getMetadataCollector().addImport( rename.isEmpty() ? name : rename, qualifiedName );
} }
} }
private static void detectMappedSuperclassProblems(ClassDetails annotatedClass) { 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 //@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() throw new AnnotationException( "Type '" + annotatedClass.getName()
+ "' is annotated both '@Entity' and '@MappedSuperclass'" ); + "' is annotated both '@Entity' and '@MappedSuperclass'" );
} }
if ( annotatedClass.hasAnnotationUsage( Table.class ) ) { if ( annotatedClass.hasDirectAnnotationUsage( Table.class ) ) {
throw new AnnotationException( "Mapped superclass '" + annotatedClass.getName() throw new AnnotationException( "Mapped superclass '" + annotatedClass.getName()
+ "' may not specify a '@Table'" ); + "' may not specify a '@Table'" );
} }
if ( annotatedClass.hasAnnotationUsage( Inheritance.class ) ) { if ( annotatedClass.hasDirectAnnotationUsage( Inheritance.class ) ) {
throw new AnnotationException( "Mapped superclass '" + annotatedClass.getName() throw new AnnotationException( "Mapped superclass '" + annotatedClass.getName()
+ "' may not specify an '@Inheritance' mapping strategy" ); + "' may not specify an '@Inheritance' mapping strategy" );
} }
@ -292,15 +297,16 @@ public final class AnnotationBinder {
.getServiceRegistry() .getServiceRegistry()
.getService( ManagedBeanRegistry.class ); .getService( ManagedBeanRegistry.class );
annotatedElement.forEachAnnotationUsage( JavaTypeRegistration.class, (usage) -> { final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( JavaTypeRegistration.class, sourceModelContext, (usage) -> {
handleJavaTypeRegistration( context, managedBeanRegistry, usage ); handleJavaTypeRegistration( context, managedBeanRegistry, usage );
} ); } );
annotatedElement.forEachAnnotationUsage( JdbcTypeRegistration.class, (usage) -> { annotatedElement.forEachAnnotationUsage( JdbcTypeRegistration.class, sourceModelContext, (usage) -> {
handleJdbcTypeRegistration( context, managedBeanRegistry, usage ); handleJdbcTypeRegistration( context, managedBeanRegistry, usage );
} ); } );
annotatedElement.forEachAnnotationUsage( CollectionTypeRegistration.class, (usage) -> { annotatedElement.forEachAnnotationUsage( CollectionTypeRegistration.class, sourceModelContext, (usage) -> {
context.getMetadataCollector().addCollectionTypeRegistration( usage ); context.getMetadataCollector().addCollectionTypeRegistration( usage );
} ); } );
} }
@ -308,12 +314,12 @@ public final class AnnotationBinder {
private static void handleJdbcTypeRegistration( private static void handleJdbcTypeRegistration(
MetadataBuildingContext context, MetadataBuildingContext context,
ManagedBeanRegistry managedBeanRegistry, ManagedBeanRegistry managedBeanRegistry,
AnnotationUsage<JdbcTypeRegistration> annotation) { JdbcTypeRegistration annotation) {
final Class<? extends JdbcType> jdbcTypeClass = annotation.getClassDetails( "value" ).toJavaClass(); final Class<? extends JdbcType> jdbcTypeClass = annotation.value();
final JdbcType jdbcType = !context.getBuildingOptions().isAllowExtensionsInCdi() final JdbcType jdbcType = !context.getBuildingOptions().isAllowExtensionsInCdi()
? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass ) ? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass )
: managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance(); : managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance();
final Integer registrationCode = annotation.getInteger( "registrationCode" ); final int registrationCode = annotation.registrationCode();
final int typeCode = registrationCode == Integer.MIN_VALUE final int typeCode = registrationCode == Integer.MIN_VALUE
? jdbcType.getDefaultSqlTypeCode() ? jdbcType.getDefaultSqlTypeCode()
: registrationCode; : registrationCode;
@ -323,13 +329,13 @@ public final class AnnotationBinder {
private static void handleJavaTypeRegistration( private static void handleJavaTypeRegistration(
MetadataBuildingContext context, MetadataBuildingContext context,
ManagedBeanRegistry managedBeanRegistry, ManagedBeanRegistry managedBeanRegistry,
AnnotationUsage<JavaTypeRegistration> annotation) { JavaTypeRegistration annotation) {
final Class<? extends BasicJavaType<?>> javaTypeClass = annotation.getClassDetails( "descriptorClass" ).toJavaClass(); final Class<? extends BasicJavaType<?>> javaTypeClass = annotation.descriptorClass();
final BasicJavaType<?> javaType = !context.getBuildingOptions().isAllowExtensionsInCdi() final BasicJavaType<?> javaType = !context.getBuildingOptions().isAllowExtensionsInCdi()
? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass ) ? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass )
: managedBeanRegistry.getBean( javaTypeClass ).getBeanInstance(); : managedBeanRegistry.getBean( javaTypeClass ).getBeanInstance();
context.getMetadataCollector().addJavaTypeRegistration( context.getMetadataCollector().addJavaTypeRegistration(
annotation.getClassDetails( "javaType" ).toJavaClass(), annotation.javaType(),
javaType javaType
); );
} }
@ -337,24 +343,27 @@ public final class AnnotationBinder {
private static void bindEmbeddableInstantiatorRegistrations( private static void bindEmbeddableInstantiatorRegistrations(
AnnotationTarget annotatedElement, AnnotationTarget annotatedElement,
MetadataBuildingContext context) { MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( EmbeddableInstantiatorRegistration.class, (usage) -> { final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( EmbeddableInstantiatorRegistration.class, sourceModelContext, (usage) -> {
handleEmbeddableInstantiatorRegistration( context, usage ); handleEmbeddableInstantiatorRegistration( context, usage );
} ); } );
} }
private static void handleEmbeddableInstantiatorRegistration( private static void handleEmbeddableInstantiatorRegistration(
MetadataBuildingContext context, MetadataBuildingContext context,
AnnotationUsage<EmbeddableInstantiatorRegistration> annotation) { EmbeddableInstantiatorRegistration annotation) {
context.getMetadataCollector().registerEmbeddableInstantiator( context.getMetadataCollector().registerEmbeddableInstantiator(
annotation.getClassDetails( "embeddableClass" ).toJavaClass(), annotation.embeddableClass(),
annotation.getClassDetails( "instantiator" ).toJavaClass() annotation.instantiator()
); );
} }
private static void bindCompositeUserTypeRegistrations( private static void bindCompositeUserTypeRegistrations(
AnnotationTarget annotatedElement, AnnotationTarget annotatedElement,
MetadataBuildingContext context) { MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( CompositeTypeRegistration.class, (usage) -> { final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( CompositeTypeRegistration.class, sourceModelContext, (usage) -> {
handleCompositeUserTypeRegistration( context, usage ); handleCompositeUserTypeRegistration( context, usage );
} ); } );
} }
@ -362,44 +371,46 @@ public final class AnnotationBinder {
private static void bindUserTypeRegistrations( private static void bindUserTypeRegistrations(
AnnotationTarget annotatedElement, AnnotationTarget annotatedElement,
MetadataBuildingContext context) { MetadataBuildingContext context) {
annotatedElement.forEachAnnotationUsage( TypeRegistration.class, (usage) -> { final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
annotatedElement.forEachAnnotationUsage( TypeRegistration.class, sourceModelContext, (usage) -> {
handleUserTypeRegistration( context, usage ); handleUserTypeRegistration( context, usage );
} ); } );
} }
private static void handleUserTypeRegistration( private static void handleUserTypeRegistration(
MetadataBuildingContext context, MetadataBuildingContext context,
AnnotationUsage<TypeRegistration> compositeTypeRegistration) { TypeRegistration compositeTypeRegistration) {
// TODO: check that the two classes agree, i.e. that // TODO: check that the two classes agree, i.e. that
// the user type knows how to handle the type // the user type knows how to handle the type
context.getMetadataCollector().registerUserType( context.getMetadataCollector().registerUserType(
compositeTypeRegistration.getClassDetails( "basicClass" ).toJavaClass(), compositeTypeRegistration.basicClass(),
compositeTypeRegistration.getClassDetails( "userType" ).toJavaClass() compositeTypeRegistration.userType()
); );
} }
private static void handleCompositeUserTypeRegistration( private static void handleCompositeUserTypeRegistration(
MetadataBuildingContext context, MetadataBuildingContext context,
AnnotationUsage<CompositeTypeRegistration> compositeTypeRegistration) { CompositeTypeRegistration compositeTypeRegistration) {
// TODO: check that the two classes agree, i.e. that // TODO: check that the two classes agree, i.e. that
// the user type knows how to handle the type // the user type knows how to handle the type
context.getMetadataCollector().registerCompositeUserType( context.getMetadataCollector().registerCompositeUserType(
compositeTypeRegistration.getClassDetails( "embeddableClass" ).toJavaClass(), compositeTypeRegistration.embeddableClass(),
compositeTypeRegistration.getClassDetails( "userType" ).toJavaClass() compositeTypeRegistration.userType()
); );
} }
private static void bindConverterRegistrations(AnnotationTarget container, MetadataBuildingContext context) { 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 ); 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( context.getMetadataCollector().getConverterRegistry().addRegisteredConversion( new RegisteredConversion(
registration.getClassDetails( "domainType" ).toJavaClass(), registration.domainType(),
registration.getClassDetails( "converter" ).toJavaClass(), registration.converter(),
registration.getBoolean( "autoApply" ), registration.autoApply(),
context context
) ); ) );
} }
@ -419,18 +430,19 @@ public final class AnnotationBinder {
} }
private static void bindFetchProfiles(AnnotationTarget annotatedElement, MetadataBuildingContext context) { 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 ); bindFetchProfile( usage, context );
} ); } );
} }
private static void bindFetchProfile(AnnotationUsage<FetchProfile> fetchProfile, MetadataBuildingContext context) { private static void bindFetchProfile(FetchProfile fetchProfile, MetadataBuildingContext context) {
final String name = fetchProfile.getString( "name" ); final String name = fetchProfile.name();
if ( reuseOrCreateFetchProfile( context, name ) ) { if ( reuseOrCreateFetchProfile( context, name ) ) {
final List<AnnotationUsage<FetchOverride>> fetchOverrides = fetchProfile.getList( "fetchOverrides" ); final FetchOverride[] fetchOverrides = fetchProfile.fetchOverrides();
for ( AnnotationUsage<FetchOverride> fetchOverride : fetchOverrides ) { for ( FetchOverride fetchOverride : fetchOverrides ) {
final FetchType type = fetchOverride.getEnum( "fetch" ); final FetchType type = fetchOverride.fetch();
final FetchMode mode = fetchOverride.getEnum( "mode" ); final FetchMode mode = fetchOverride.mode();
if ( type == FetchType.LAZY && mode == FetchMode.JOIN ) { if ( type == FetchType.LAZY && mode == FetchMode.JOIN ) {
throw new AnnotationException( throw new AnnotationException(
"Fetch profile '" + name "Fetch profile '" + name
@ -476,7 +488,7 @@ public final class AnnotationBinder {
final InheritanceState superclassState = getSuperclassInheritanceState( clazz, inheritanceStatePerClass ); final InheritanceState superclassState = getSuperclassInheritanceState( clazz, inheritanceStatePerClass );
final InheritanceState state = new InheritanceState( clazz, inheritanceStatePerClass, buildingContext ); final InheritanceState state = new InheritanceState( clazz, inheritanceStatePerClass, buildingContext );
final AnnotatedClassType classType = buildingContext.getMetadataCollector().getClassType( clazz ); 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(); final String className = clazz.getName();
buildingContext.getMetadataCollector().addImport( unqualify( className ), className ); 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.lang.reflect.ParameterizedType;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Parameter;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor; 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.boot.spi.MetadataBuildingContext;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer; import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBean; import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
@ -41,11 +39,11 @@ import static org.hibernate.internal.util.collections.CollectionHelper.mapOfSize
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class AnnotationHelper { public class AnnotationHelper {
public static HashMap<String, String> extractParameterMap(List<AnnotationUsage<Parameter>> parameters) { public static HashMap<String, String> extractParameterMap(Parameter[] parameters) {
final HashMap<String,String> paramMap = mapOfSize( parameters.size() ); final HashMap<String,String> paramMap = mapOfSize( parameters.length );
parameters.forEach( (usage) -> { for ( int i = 0; i < parameters.length; i++ ) {
paramMap.put( usage.getString( "name" ), usage.getString( "value" ) ); paramMap.put( parameters[i].name(), parameters[i].value() );
} ); }
return paramMap; return paramMap;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,8 @@
*/ */
package org.hibernate.boot.model.internal; package org.hibernate.boot.model.internal;
import jakarta.persistence.JoinTable; import java.util.Map;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
import org.hibernate.boot.spi.InFlightMetadataCollector; import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
@ -17,9 +18,8 @@ import org.hibernate.mapping.Join;
import org.hibernate.mapping.ManyToOne; import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table; 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.boot.model.internal.ToOneBinder.getReferenceEntityName;
import static org.hibernate.internal.util.StringHelper.isEmpty; import static org.hibernate.internal.util.StringHelper.isEmpty;
@ -38,7 +38,7 @@ public class ImplicitToOneJoinTableSecondPass implements SecondPass {
private final PropertyData inferredData; private final PropertyData inferredData;
private final MetadataBuildingContext context; private final MetadataBuildingContext context;
private final AnnotatedJoinColumns joinColumns; private final AnnotatedJoinColumns joinColumns;
private final AnnotationUsage<JoinTable> joinTable; private final JoinTable joinTable;
private final NotFoundAction notFoundAction; private final NotFoundAction notFoundAction;
private final ManyToOne value; private final ManyToOne value;
@ -47,7 +47,7 @@ public class ImplicitToOneJoinTableSecondPass implements SecondPass {
PropertyData inferredData, PropertyData inferredData,
MetadataBuildingContext context, MetadataBuildingContext context,
AnnotatedJoinColumns joinColumns, AnnotatedJoinColumns joinColumns,
AnnotationUsage<JoinTable> joinTable, JoinTable joinTable,
NotFoundAction notFoundAction, NotFoundAction notFoundAction,
ManyToOne value) { ManyToOne value) {
this.propertyHolder = propertyHolder; this.propertyHolder = propertyHolder;
@ -89,24 +89,24 @@ public class ImplicitToOneJoinTableSecondPass implements SecondPass {
final TableBinder tableBinder = new TableBinder(); final TableBinder tableBinder = new TableBinder();
tableBinder.setBuildingContext( context ); tableBinder.setBuildingContext( context );
final String schema = joinTable.getString( "schema" ); final String schema = joinTable.schema();
if ( StringHelper.isNotEmpty( schema ) ) { if ( StringHelper.isNotEmpty( schema ) ) {
tableBinder.setSchema( schema ); tableBinder.setSchema( schema );
} }
final String catalog = joinTable.getString( "catalog" ); final String catalog = joinTable.catalog();
if ( StringHelper.isNotEmpty( catalog ) ) { if ( StringHelper.isNotEmpty( catalog ) ) {
tableBinder.setCatalog( catalog ); tableBinder.setCatalog( catalog );
} }
final String tableName = joinTable.getString( "name" ); final String tableName = joinTable.name();
if ( StringHelper.isNotEmpty( tableName ) ) { if ( StringHelper.isNotEmpty( tableName ) ) {
tableBinder.setName( tableName ); tableBinder.setName( tableName );
} }
tableBinder.setUniqueConstraints( joinTable.getList( "uniqueConstraints" ) ); tableBinder.setUniqueConstraints( joinTable.uniqueConstraints() );
tableBinder.setJpaIndex( joinTable.getList( "indexes" ) ); tableBinder.setJpaIndex( joinTable.indexes() );
tableBinder.setOptions( joinTable.getString( "options" ) ); tableBinder.setOptions( joinTable.options() );
return tableBinder; 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.model.relational.Database;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.Formula; import org.hibernate.mapping.Formula;
import org.hibernate.mapping.Index; import org.hibernate.mapping.Index;
import org.hibernate.mapping.Selectable; import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.UniqueKey;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
@ -115,8 +113,8 @@ class IndexBinder {
return new Column( physicalName ); return new Column( physicalName );
} }
private Selectable[] selectables(Table table, String name, List<String> columnNames) { private Selectable[] selectables(Table table, String name, String[] columnNames) {
final int size = columnNames.size(); final int size = columnNames.length;
if ( size == 0 ) { if ( size == 0 ) {
throw new AnnotationException( "Index" throw new AnnotationException( "Index"
+ ( isEmpty( name ) ? "" : " '" + name + "'" ) + ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -124,7 +122,7 @@ class IndexBinder {
} }
final Selectable[] columns = new Selectable[size]; final Selectable[] columns = new Selectable[size];
for ( int index = 0; index < size; index++ ) { for ( int index = 0; index < size; index++ ) {
final String columnName = columnNames.get( index ); final String columnName = columnNames[index];
if ( isEmpty( columnName ) ) { if ( isEmpty( columnName ) ) {
throw new AnnotationException( "Index" throw new AnnotationException( "Index"
+ ( isEmpty( name ) ? "" : " '" + name + "'" ) + ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -135,8 +133,8 @@ class IndexBinder {
return columns; return columns;
} }
private Column[] columns(Table table, String name, final List<String> columnNames) { private Column[] columns(Table table, String name, final String[] columnNames) {
final int size = columnNames.size(); final int size = columnNames.length;
if ( size == 0 ) { if ( size == 0 ) {
throw new AnnotationException( "Unique constraint" throw new AnnotationException( "Unique constraint"
+ ( isEmpty( name ) ? "" : " '" + name + "'" ) + ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -144,7 +142,7 @@ class IndexBinder {
} }
final Column[] columns = new Column[size]; final Column[] columns = new Column[size];
for ( int index = 0; index < size; index++ ) { for ( int index = 0; index < size; index++ ) {
final String columnName = columnNames.get( index ); final String columnName = columnNames[index];
if ( isEmpty( columnName ) ) { if ( isEmpty( columnName ) ) {
throw new AnnotationException( "Unique constraint" throw new AnnotationException( "Unique constraint"
+ ( isEmpty( name ) ? "" : " '" + name + "'" ) + ( isEmpty( name ) ? "" : " '" + name + "'" )
@ -159,7 +157,7 @@ class IndexBinder {
Table table, Table table,
String originalKeyName, String originalKeyName,
boolean nameExplicit, boolean nameExplicit,
List<String> columnNames, String[] columnNames,
String[] orderings, String[] orderings,
boolean unique, boolean unique,
Selectable[] columns) { Selectable[] columns) {
@ -190,9 +188,9 @@ class IndexBinder {
} }
} }
void bindIndexes(Table table, List<AnnotationUsage<jakarta.persistence.Index>> indexes) { void bindIndexes(Table table, jakarta.persistence.Index[] indexes) {
for ( AnnotationUsage<jakarta.persistence.Index> index : indexes ) { for ( jakarta.persistence.Index index : indexes ) {
final StringTokenizer tokenizer = new StringTokenizer( index.getString( "columnList" ), "," ); final StringTokenizer tokenizer = new StringTokenizer( index.columnList(), "," );
final List<String> parsed = new ArrayList<>(); final List<String> parsed = new ArrayList<>();
while ( tokenizer.hasMoreElements() ) { while ( tokenizer.hasMoreElements() ) {
final String trimmed = tokenizer.nextToken().trim(); final String trimmed = tokenizer.nextToken().trim();
@ -200,11 +198,11 @@ class IndexBinder {
parsed.add( trimmed ) ; 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()]; final String[] ordering = new String[parsed.size()];
initializeColumns( columnExpressions, ordering, parsed ); initializeColumns( columnExpressions, ordering, parsed );
final String name = index.getString( "name" ); final String name = index.name();
final boolean unique = index.getBoolean( "unique" ); final boolean unique = index.unique();
createIndexOrUniqueKey( createIndexOrUniqueKey(
table, table,
name, name,
@ -217,10 +215,10 @@ class IndexBinder {
} }
} }
void bindUniqueConstraints(Table table, List<AnnotationUsage<UniqueConstraint>> constraints) { void bindUniqueConstraints(Table table, UniqueConstraint[] constraints) {
for ( AnnotationUsage<UniqueConstraint> constraint : constraints ) { for ( UniqueConstraint constraint : constraints ) {
final String name = constraint.getString( "name" ); final String name = constraint.name();
final List<String> columnNames = constraint.getList( "columnNames" ); final String[] columnNames = constraint.columnNames();
createIndexOrUniqueKey( createIndexOrUniqueKey(
table, table,
name, 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++ ) { for ( int i = 0, size = list.size(); i < size; i++ ) {
final String description = list.get( i ); final String description = list.get( i );
final String tmp = description.toLowerCase(Locale.ROOT); final String tmp = description.toLowerCase(Locale.ROOT);
if ( tmp.endsWith( " desc" ) ) { if ( tmp.endsWith( " desc" ) ) {
columns.set( i, description.substring( 0, description.length() - 5 ) ); columns[i] = description.substring( 0, description.length() - 5 );
ordering[i] = "desc"; ordering[i] = "desc";
} }
else if ( tmp.endsWith( " asc" ) ) { 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"; ordering[i] = "asc";
} }
else { else {
columns.set( i, description ); columns[i] = description;
ordering[i] = null; ordering[i] = null;
} }
} }
@ -255,10 +253,10 @@ class IndexBinder {
private class IndexOrUniqueKeyNameSource implements ImplicitIndexNameSource, ImplicitUniqueKeyNameSource { private class IndexOrUniqueKeyNameSource implements ImplicitIndexNameSource, ImplicitUniqueKeyNameSource {
private final MetadataBuildingContext buildingContext; private final MetadataBuildingContext buildingContext;
private final Table table; private final Table table;
private final List<String> columnNames; private final String[] columnNames;
private final String originalKeyName; 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.buildingContext = buildingContext;
this.table = table; this.table = table;
this.columnNames = columnNames; 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 ) { if ( names == null ) {
return emptyList(); return emptyList();
} }
final List<Identifier> columnNames = arrayList( names.size() ); final List<Identifier> columnNames = arrayList( names.length );
for ( String name : names ) { for ( String name : names ) {
columnNames.add( getDatabase().toIdentifier( name ) ); 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.MetadataBuildingContext;
import org.hibernate.boot.spi.PropertyData; import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
@ -33,9 +32,9 @@ public class IndexColumn extends AnnotatedColumn {
} }
public static IndexColumn fromAnnotations( public static IndexColumn fromAnnotations(
AnnotationUsage<OrderColumn> orderColumn, OrderColumn orderColumn,
AnnotationUsage<org.hibernate.annotations.IndexColumn> indexColumn, org.hibernate.annotations.IndexColumn indexColumn,
AnnotationUsage<ListIndexBase> listIndexBase, ListIndexBase listIndexBase,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
@ -46,7 +45,7 @@ public class IndexColumn extends AnnotatedColumn {
} }
else if ( indexColumn != null ) { else if ( indexColumn != null ) {
column = buildColumnFromIndexColumn( indexColumn, propertyHolder, inferredData, context ); column = buildColumnFromIndexColumn( indexColumn, propertyHolder, inferredData, context );
column.setBase( indexColumn.getInteger( "base" ) ); column.setBase( indexColumn.base() );
} }
else { else {
column = new IndexColumn(); column = new IndexColumn();
@ -59,7 +58,7 @@ public class IndexColumn extends AnnotatedColumn {
} }
if ( listIndexBase != null ) { if ( listIndexBase != null ) {
column.setBase( listIndexBase.getInteger( "value" ) ); column.setBase( listIndexBase.value() );
} }
return column; return column;
@ -96,25 +95,25 @@ public class IndexColumn extends AnnotatedColumn {
* @return The index column * @return The index column
*/ */
public static IndexColumn buildColumnFromOrderColumn( public static IndexColumn buildColumnFromOrderColumn(
AnnotationUsage<OrderColumn> orderColumn, OrderColumn orderColumn,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
MetadataBuildingContext context) { MetadataBuildingContext context) {
if ( orderColumn != null ) { if ( orderColumn != null ) {
final String sqlType = nullIfEmpty( orderColumn.getString( "columnDefinition" ) ); final String sqlType = nullIfEmpty( orderColumn.columnDefinition() );
final String explicitName = orderColumn.getString( "name" ); final String explicitName = orderColumn.name();
final String name = explicitName.isEmpty() final String name = explicitName.isEmpty()
? inferredData.getPropertyName() + "_ORDER" ? inferredData.getPropertyName() + "_ORDER"
: explicitName; : explicitName;
final IndexColumn column = new IndexColumn(); final IndexColumn column = new IndexColumn();
column.setLogicalColumnName( name ); column.setLogicalColumnName( name );
column.setSqlType( sqlType ); column.setSqlType( sqlType );
column.setNullable( orderColumn.getBoolean( "nullable" ) ); column.setNullable( orderColumn.nullable() );
// column.setJoins( secondaryTables ); // column.setJoins( secondaryTables );
column.setInsertable( orderColumn.getBoolean( "insertable" ) ); column.setInsertable( orderColumn.insertable() );
column.setUpdatable( orderColumn.getBoolean( "updatable" ) ); column.setUpdatable( orderColumn.updatable() );
column.setOptions( orderColumn.getString( "options" ) ); column.setOptions( orderColumn.options() );
// column.setContext( context ); // column.setContext( context );
// column.setPropertyHolder( propertyHolder ); // column.setPropertyHolder( propertyHolder );
createParent( propertyHolder, secondaryTables, column, context ); createParent( propertyHolder, secondaryTables, column, context );
@ -142,22 +141,22 @@ public class IndexColumn extends AnnotatedColumn {
* @return The index column * @return The index column
*/ */
public static IndexColumn buildColumnFromIndexColumn( public static IndexColumn buildColumnFromIndexColumn(
AnnotationUsage<org.hibernate.annotations.IndexColumn> indexColumn, org.hibernate.annotations.IndexColumn indexColumn,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
MetadataBuildingContext context) { MetadataBuildingContext context) {
if ( indexColumn != null ) { if ( indexColumn != null ) {
final String explicitName = indexColumn.getString( "name" ); final String explicitName = indexColumn.name();
final String name = explicitName.isEmpty() final String name = explicitName.isEmpty()
? inferredData.getPropertyName() ? inferredData.getPropertyName()
: explicitName; : 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 //TODO move it to a getter based system and remove the constructor
final IndexColumn column = new IndexColumn(); final IndexColumn column = new IndexColumn();
column.setLogicalColumnName( name ); column.setLogicalColumnName( name );
column.setSqlType( sqlType ); column.setSqlType( sqlType );
column.setNullable( indexColumn.getBoolean( "nullable" ) ); column.setNullable( indexColumn.nullable() );
column.setBase( indexColumn.getInteger( "base" ) ); column.setBase( indexColumn.base() );
// column.setContext( context ); // column.setContext( context );
// column.setPropertyHolder( propertyHolder ); // column.setPropertyHolder( propertyHolder );
createParent( propertyHolder, null, column, context ); createParent( propertyHolder, null, column, context );

View File

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

View File

@ -20,7 +20,6 @@ import org.hibernate.mapping.List;
import org.hibernate.mapping.OneToMany; import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.spi.ManagedBean; import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.usertype.UserCollectionType; import org.hibernate.usertype.UserCollectionType;
@ -50,7 +49,7 @@ public class ListBinder extends CollectionBinder {
} }
@Override @Override
public void setSqlOrderBy(AnnotationUsage<OrderBy> orderByAnn) { public void setSqlOrderBy(OrderBy orderByAnn) {
if ( orderByAnn != null ) { if ( orderByAnn != null ) {
throw new AnnotationException( "A collection of type 'List' is annotated '@OrderBy'" ); 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.Table;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.models.internal.ClassTypeDetailsImpl; import org.hibernate.models.internal.ClassTypeDetailsImpl;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails; import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails; import org.hibernate.models.spi.TypeDetails;
@ -112,7 +111,7 @@ public class MapBinder extends CollectionBinder {
private void makeOneToManyMapKeyColumnNullableIfNotInProperty(MemberDetails property) { private void makeOneToManyMapKeyColumnNullableIfNotInProperty(MemberDetails property) {
final Map map = (Map) this.collection; 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(); final Value indexValue = map.getIndex();
if ( indexValue.getColumnSpan() != 1 ) { if ( indexValue.getColumnSpan() != 1 ) {
throw new AssertionFailure( "Map key mapped by @MapKeyColumn does not have 1 column" ); 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) { private static String getKeyType(MemberDetails property) {
//target has priority over reflection for the map key type //target has priority over reflection for the map key type
//JPA 2 has priority //JPA 2 has priority
final AnnotationUsage<MapKeyClass> mapKeyClassAnn = property.getAnnotationUsage( MapKeyClass.class ); final MapKeyClass mapKeyClassAnn = property.getDirectAnnotationUsage( MapKeyClass.class );
final Class<?> target = mapKeyClassAnn != null final Class<?> target = mapKeyClassAnn != null
? mapKeyClassAnn.getClassDetails( "value" ).toJavaClass() ? mapKeyClassAnn.value()
: void.class; : void.class;
return void.class.equals( target ) ? property.getMapKeyType().getName() : target.getName(); 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) { private void handleForeignKey(MemberDetails property, ManyToOne element) {
final AnnotationUsage<ForeignKey> foreignKey = getMapKeyForeignKey( property ); final ForeignKey foreignKey = getMapKeyForeignKey( property );
if ( foreignKey != null ) { if ( foreignKey != null ) {
final ConstraintMode constraintMode = foreignKey.getEnum( "value" ); final ConstraintMode constraintMode = foreignKey.value();
if ( constraintMode == ConstraintMode.NO_CONSTRAINT if ( constraintMode == ConstraintMode.NO_CONSTRAINT
|| constraintMode == ConstraintMode.PROVIDER_DEFAULT && getBuildingContext().getBuildingOptions().isNoConstraintByDefault() ) { || constraintMode == ConstraintMode.PROVIDER_DEFAULT && getBuildingContext().getBuildingOptions().isNoConstraintByDefault() ) {
element.disableForeignKey(); element.disableForeignKey();
} }
else { else {
element.setForeignKeyName( nullIfEmpty( foreignKey.getString( "name" ) ) ); element.setForeignKeyName( nullIfEmpty( foreignKey.name() ) );
element.setForeignKeyDefinition( nullIfEmpty( foreignKey.getString( "foreignKeyDefinition" ) ) ); element.setForeignKeyDefinition( nullIfEmpty( foreignKey.foreignKeyDefinition() ) );
} }
} }
} }
@ -378,7 +377,7 @@ public class MapBinder extends CollectionBinder {
accessType, accessType,
//TODO be smart with isNullable //TODO be smart with isNullable
true, true,
new EntityBinder(), new EntityBinder( buildingContext ),
false, false,
false, false,
true, true,
@ -401,10 +400,9 @@ public class MapBinder extends CollectionBinder {
MemberDetails property, MemberDetails property,
TypeDetails returnedClass, TypeDetails returnedClass,
MetadataBuildingContext context) { MetadataBuildingContext context) {
final AnnotationUsage<MapKeyCompositeType> compositeType = property.getAnnotationUsage( MapKeyCompositeType.class ); final MapKeyCompositeType compositeType = property.getDirectAnnotationUsage( MapKeyCompositeType.class );
if ( compositeType != null ) { if ( compositeType != null ) {
final ClassDetails compositeTypeImplDetails = compositeType.getClassDetails( "value" ); return compositeType.value();
return compositeTypeImplDetails.toJavaClass();
} }
if ( returnedClass != null ) { if ( returnedClass != null ) {
@ -414,28 +412,30 @@ public class MapBinder extends CollectionBinder {
return null; return null;
} }
private AnnotationUsage<jakarta.persistence.ForeignKey> getMapKeyForeignKey(MemberDetails property) { private jakarta.persistence.ForeignKey getMapKeyForeignKey(MemberDetails property) {
final AnnotationUsage<MapKeyJoinColumns> mapKeyJoinColumns = property.getAnnotationUsage( MapKeyJoinColumns.class ); final MapKeyJoinColumns mapKeyJoinColumns = property.getDirectAnnotationUsage( MapKeyJoinColumns.class );
final AnnotationUsage<MapKeyJoinColumn> mapKeyJoinColumn = property.getSingleAnnotationUsage( MapKeyJoinColumn.class );
if ( mapKeyJoinColumns != null ) { 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; return null;
} }
}
private boolean mappingDefinedAttributeOverrideOnMapKey(MemberDetails property) { private boolean mappingDefinedAttributeOverrideOnMapKey(MemberDetails property) {
if ( property.hasAnnotationUsage( AttributeOverride.class ) ) { final AttributeOverride overrideAnn = property.getDirectAnnotationUsage( AttributeOverride.class );
return namedMapKey( property.getAnnotationUsage( AttributeOverride.class ) ); if ( overrideAnn != null ) {
return namedMapKey( overrideAnn );
} }
if ( property.hasAnnotationUsage( AttributeOverrides.class ) ) {
final AnnotationUsage<AttributeOverrides> annotations = property.getAnnotationUsage( AttributeOverrides.class ); final AttributeOverrides overridesAnn = property.getDirectAnnotationUsage( AttributeOverrides.class );
for ( AnnotationUsage<AttributeOverride> attributeOverride : annotations.<AnnotationUsage<AttributeOverride>>getList( "value" ) ) { if ( overridesAnn != null ) {
if ( namedMapKey( attributeOverride ) ) { for ( AttributeOverride nestedAnn : overridesAnn.value() ) {
if ( namedMapKey( nestedAnn ) ) {
return true; return true;
} }
} }
@ -443,8 +443,8 @@ public class MapBinder extends CollectionBinder {
return false; return false;
} }
private boolean namedMapKey(AnnotationUsage<AttributeOverride> annotation) { private boolean namedMapKey(AttributeOverride annotation) {
return annotation.getString( "name" ).startsWith( "key." ); return annotation.name().startsWith( "key." );
} }
private Value createFormulatedValue( 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.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.SortableValue; 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.models.spi.MemberDetails;
import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.ForeignKeyDirection;
@ -105,7 +103,7 @@ public class OneToOneSecondPass implements SecondPass {
value.setConstrained( !optional ); value.setConstrained( !optional );
value.setForeignKeyType( getForeignKeyDirection() ); value.setForeignKeyType( getForeignKeyDirection() );
bindForeignKeyNameAndDefinition( value, property, property.getAnnotationUsage( ForeignKey.class ), buildingContext ); bindForeignKeyNameAndDefinition( value, property, property.getDirectAnnotationUsage( ForeignKey.class ), buildingContext );
final PropertyBinder binder = new PropertyBinder(); final PropertyBinder binder = new PropertyBinder();
binder.setName( propertyName ); binder.setName( propertyName );
@ -116,9 +114,9 @@ public class OneToOneSecondPass implements SecondPass {
binder.setBuildingContext( buildingContext ); binder.setBuildingContext( buildingContext );
binder.setHolder( propertyHolder ); binder.setHolder( propertyHolder );
final AnnotationUsage<LazyGroup> lazyGroupAnnotation = property.getAnnotationUsage( LazyGroup.class ); final LazyGroup lazyGroupAnnotation = property.getDirectAnnotationUsage( LazyGroup.class );
if ( lazyGroupAnnotation != null ) { if ( lazyGroupAnnotation != null ) {
binder.setLazyGroup( lazyGroupAnnotation.getString( "value" ) ); binder.setLazyGroup( lazyGroupAnnotation.value() );
} }
final Property result = binder.makeProperty(); final Property result = binder.makeProperty();

View File

@ -9,6 +9,7 @@ package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.hibernate.AnnotationException; 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.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitUniqueKeyNameSource; import org.hibernate.boot.model.naming.ImplicitUniqueKeyNameSource;
import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.spi.AccessType; import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.InFlightMetadataCollector; import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
@ -42,6 +44,7 @@ import org.hibernate.generator.BeforeExecutionGenerator;
import org.hibernate.generator.EventType; import org.hibernate.generator.EventType;
import org.hibernate.generator.EventTypeSets; import org.hibernate.generator.EventTypeSets;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
import org.hibernate.mapping.GeneratorCreator; import org.hibernate.mapping.GeneratorCreator;
@ -55,18 +58,15 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.metamodel.spi.EmbeddableInstantiator; 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.ClassDetails;
import org.hibernate.models.spi.MemberDetails; import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails; import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableScope; 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.usertype.CompositeUserType;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import jakarta.persistence.Basic; 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.boot.model.naming.Identifier.toIdentifier;
import static org.hibernate.id.IdentifierGeneratorHelper.getForeignId; import static org.hibernate.id.IdentifierGeneratorHelper.getForeignId;
import static org.hibernate.internal.util.StringHelper.qualify; 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. * A stateful binder responsible for creating {@link Property} objects.
@ -139,6 +138,10 @@ public class PropertyBinder {
private boolean toMany; private boolean toMany;
private String referencedEntityName; private String referencedEntityName;
protected SourceModelBuildingContext getSourceModelContext() {
return buildingContext.getMetadataCollector().getSourceModelBuildingContext();
}
public void setReferencedEntityName(String referencedEntityName) { public void setReferencedEntityName(String referencedEntityName) {
this.referencedEntityName = referencedEntityName; this.referencedEntityName = referencedEntityName;
} }
@ -286,17 +289,29 @@ public class PropertyBinder {
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
private void callAttributeBinders(Property property, Map<String, PersistentClass> persistentClasses) { private void callAttributeBinders(Property property, Map<String, PersistentClass> persistentClasses) {
for ( AnnotationUsage<?> binderAnnotationUsage : memberDetails.getMetaAnnotated( AttributeBinderType.class ) ) { final List<? extends Annotation> metaAnnotatedTargets = memberDetails.getMetaAnnotated(
final AttributeBinderType binderType = binderAnnotationUsage.getAnnotationType().getAnnotation( AttributeBinderType.class ); 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 { try {
final AttributeBinder binder = binderType.binder().getConstructor().newInstance(); final AttributeBinder binder = binderTypeAnn.binder().getConstructor().newInstance();
final PersistentClass persistentClass = entityBinder != null final PersistentClass persistentClass = entityBinder != null
? entityBinder.getPersistentClass() ? entityBinder.getPersistentClass()
: persistentClasses.get( holder.getEntityName() ); : persistentClasses.get( holder.getEntityName() );
binder.bind( binderAnnotationUsage.toAnnotation(), buildingContext, persistentClass, property ); binder.bind( metaAnnotatedTarget, buildingContext, persistentClass, property );
} }
catch ( Exception e ) { 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) { private Class<? extends EmbeddableInstantiator> resolveCustomInstantiator(
if ( property.hasAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class ) ) { MemberDetails property,
final AnnotationUsage<org.hibernate.annotations.EmbeddableInstantiator> annotationUsage = property.getAnnotationUsage( ClassDetails embeddableClass) {
org.hibernate.annotations.EmbeddableInstantiator.class ); final org.hibernate.annotations.EmbeddableInstantiator onEmbedded = property.getDirectAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
return annotationUsage.getClassDetails( "value" ).toJavaClass(); if ( onEmbedded != null ) {
return onEmbedded.value();
} }
else if ( embeddableClass.hasAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class ) ) {
final AnnotationUsage<org.hibernate.annotations.EmbeddableInstantiator> annotationUsage = embeddableClass.getAnnotationUsage( final org.hibernate.annotations.EmbeddableInstantiator onEmbeddable = embeddableClass.getDirectAnnotationUsage( org.hibernate.annotations.EmbeddableInstantiator.class );
org.hibernate.annotations.EmbeddableInstantiator.class ); if ( onEmbeddable != null ) {
return annotationUsage.getClassDetails( "value" ).toJavaClass(); return onEmbeddable.value();
} }
else {
return null; return null;
} }
}
//used when the value is provided and the binding is done elsewhere //used when the value is provided and the binding is done elsewhere
public Property makeProperty() { public Property makeProperty() {
@ -443,10 +458,13 @@ public class PropertyBinder {
* Returns the value generation strategy for the given property, if any. * Returns the value generation strategy for the given property, if any.
*/ */
private GeneratorCreator getValueGenerationFromAnnotations(MemberDetails property) { private GeneratorCreator getValueGenerationFromAnnotations(MemberDetails property) {
final BeanContainer beanContainer = beanContainer( buildingContext );
GeneratorCreator creator = null; GeneratorCreator creator = null;
for ( AnnotationUsage<?> usage : property.getAllAnnotationUsages() ) { final List<? extends Annotation> metaAnnotatedTargets = property.getMetaAnnotated(
final GeneratorCreator candidate = generatorCreator( property, usage, beanContainer ); ValueGenerationType.class,
getSourceModelContext()
);
for ( Annotation metaAnnotatedTarget : metaAnnotatedTargets ) {
final GeneratorCreator candidate = generatorCreator( property, metaAnnotatedTarget, beanContainer( buildingContext ) );
if ( candidate != null ) { if ( candidate != null ) {
if ( creator != null ) { if ( creator != null ) {
throw new AnnotationException( "Property '" + qualify( holder.getPath(), name ) throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
@ -463,12 +481,12 @@ public class PropertyBinder {
private void handleLob(Property property) { private void handleLob(Property property) {
if ( this.memberDetails != null ) { if ( this.memberDetails != null ) {
// HHH-4635 -- needed for dialect-specific property ordering // 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) { 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; updatable = false;
} }
property.setInsertable( insertable ); property.setInsertable( insertable );
@ -507,14 +525,14 @@ public class PropertyBinder {
private void handleNaturalId(Property property) { private void handleNaturalId(Property property) {
if ( this.memberDetails != null && entityBinder != null ) { 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 ( naturalId != null ) {
if ( !entityBinder.isRootEntity() ) { if ( !entityBinder.isRootEntity() ) {
throw new AnnotationException( "Property '" + qualify( holder.getPath(), name ) throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
+ "' belongs to an entity subclass and may not be annotated '@NaturalId'" + + "' 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')" ); " (only a property of a root '@Entity' or a '@MappedSuperclass' may be a '@NaturalId')" );
} }
if ( !naturalId.getBoolean( "mutable" ) ) { if ( !naturalId.mutable() ) {
updatable = false; updatable = false;
} }
property.setNaturalIdentifier( true ); property.setNaturalIdentifier( true );
@ -527,9 +545,9 @@ public class PropertyBinder {
if ( value instanceof Collection ) { if ( value instanceof Collection ) {
property.setOptimisticLocked( ((Collection) value).isOptimisticLocked() ); property.setOptimisticLocked( ((Collection) value).isOptimisticLocked() );
} }
else if ( this.memberDetails != null && this.memberDetails.hasAnnotationUsage( OptimisticLock.class ) ) { else if ( this.memberDetails != null && this.memberDetails.hasDirectAnnotationUsage( OptimisticLock.class ) ) {
final AnnotationUsage<OptimisticLock> optimisticLock = this.memberDetails.getAnnotationUsage( OptimisticLock.class ); final OptimisticLock optimisticLock = this.memberDetails.getDirectAnnotationUsage( OptimisticLock.class );
final boolean excluded = optimisticLock.getBoolean( "excluded" ); final boolean excluded = optimisticLock.excluded();
validateOptimisticLock( excluded ); validateOptimisticLock( excluded );
property.setOptimisticLocked( !excluded ); property.setOptimisticLocked( !excluded );
} }
@ -540,15 +558,15 @@ public class PropertyBinder {
private void validateOptimisticLock(boolean excluded) { private void validateOptimisticLock(boolean excluded) {
if ( excluded ) { if ( excluded ) {
if ( memberDetails.hasAnnotationUsage( Version.class ) ) { if ( memberDetails.hasDirectAnnotationUsage( Version.class ) ) {
throw new AnnotationException("Property '" + qualify( holder.getPath(), name ) throw new AnnotationException("Property '" + qualify( holder.getPath(), name )
+ "' is annotated '@OptimisticLock(excluded=true)' and '@Version'" ); + "' 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 ) throw new AnnotationException("Property '" + qualify( holder.getPath(), name )
+ "' is annotated '@OptimisticLock(excluded=true)' and '@Id'" ); + "' 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 ) throw new AnnotationException( "Property '" + qualify( holder.getPath(), name )
+ "' is annotated '@OptimisticLock(excluded=true)' and '@EmbeddedId'" ); + "' is annotated '@OptimisticLock(excluded=true)' and '@EmbeddedId'" );
} }
@ -613,7 +631,7 @@ public class PropertyBinder {
else { else {
inFlightPropertyDataList.add( propertyAnnotatedElement ); inFlightPropertyDataList.add( propertyAnnotatedElement );
} }
if ( element.hasAnnotationUsage( MapsId.class ) ) { if ( element.hasDirectAnnotationUsage( MapsId.class ) ) {
context.getMetadataCollector().addPropertyAnnotatedWithMapsId( ownerType.determineRawClass(), propertyAnnotatedElement ); context.getMetadataCollector().addPropertyAnnotatedWithMapsId( ownerType.determineRawClass(), propertyAnnotatedElement );
} }
@ -621,8 +639,8 @@ public class PropertyBinder {
} }
private static void checkIdProperty(MemberDetails property, PropertyData propertyData) { private static void checkIdProperty(MemberDetails property, PropertyData propertyData) {
final AnnotationUsage<Id> incomingIdProperty = property.getAnnotationUsage( Id.class ); final Id incomingIdProperty = property.getDirectAnnotationUsage( Id.class );
final AnnotationUsage<Id> existingIdProperty = propertyData.getAttributeMember().getAnnotationUsage( Id.class ); final Id existingIdProperty = propertyData.getAttributeMember().getDirectAnnotationUsage( Id.class );
if ( incomingIdProperty != null && existingIdProperty == null ) { if ( incomingIdProperty != null && existingIdProperty == null ) {
throw new MappingException( throw new MappingException(
String.format( String.format(
@ -645,11 +663,12 @@ public class PropertyBinder {
//TODO support true/false/default on the property instead of present / not present //TODO support true/false/default on the property instead of present / not present
//TODO is @Column mandatory? //TODO is @Column mandatory?
//TODO add method support //TODO add method support
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) { if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) {
if ( element.hasAnnotationUsage( Id.class ) && element.hasAnnotationUsage( Column.class ) ) { if ( element.hasDirectAnnotationUsage( Id.class ) && element.hasDirectAnnotationUsage( Column.class ) ) {
final String columnName = element.getAnnotationUsage( Column.class ).getString( "name" ); final String columnName = element.getDirectAnnotationUsage( Column.class ).name();
declaringClass.forEachField( (index, fieldDetails) -> { 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 //create a PropertyData for the specJ property holding the mapping
context.getMetadataCollector().addPropertyAnnotatedWithMapsIdSpecj( context.getMetadataCollector().addPropertyAnnotatedWithMapsIdSpecj(
ownerType.determineRawClass(), 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 //The detection of a configured individual JoinColumn differs between Annotation
//and XML configuration processing. //and XML configuration processing.
final List<AnnotationUsage<JoinColumn>> joinColumnAnnotations = property.getRepeatedAnnotationUsages( JoinColumn.class ); final JoinColumn[] joinColumnAnnotations = property.getRepeatedAnnotationUsages(
for ( AnnotationUsage<JoinColumn> joinColumnAnnotation : joinColumnAnnotations ) { JpaAnnotations.JOIN_COLUMN,
if ( joinColumnAnnotation.getString( "name" ).equals( columnName ) ) { modelContext
);
for ( JoinColumn joinColumnAnnotation : joinColumnAnnotations ) {
if ( joinColumnAnnotation.name().equals( columnName ) ) {
return true; return true;
} }
} }
@ -684,8 +706,8 @@ public class PropertyBinder {
} }
static boolean hasIdAnnotation(MemberDetails element) { static boolean hasIdAnnotation(MemberDetails element) {
return element.hasAnnotationUsage( Id.class ) return element.hasDirectAnnotationUsage( Id.class )
|| element.hasAnnotationUsage( EmbeddedId.class ); || element.hasDirectAnnotationUsage( EmbeddedId.class );
} }
/** /**
@ -724,7 +746,7 @@ public class PropertyBinder {
} }
final MemberDetails property = inferredData.getAttributeMember(); final MemberDetails property = inferredData.getAttributeMember();
if ( property.hasAnnotationUsage( Parent.class ) ) { if ( property.hasDirectAnnotationUsage( Parent.class ) ) {
handleParentProperty( propertyHolder, inferredData, property ); handleParentProperty( propertyHolder, inferredData, property );
} }
else { else {
@ -803,9 +825,9 @@ public class PropertyBinder {
propertyBinder.setInheritanceStatePerClass( inheritanceStatePerClass ); propertyBinder.setInheritanceStatePerClass( inheritanceStatePerClass );
propertyBinder.setId( !entityBinder.isIgnoreIdAnnotations() && hasIdAnnotation( property ) ); propertyBinder.setId( !entityBinder.isIgnoreIdAnnotations() && hasIdAnnotation( property ) );
final AnnotationUsage<LazyGroup> lazyGroupAnnotation = property.getAnnotationUsage( LazyGroup.class ); final LazyGroup lazyGroupAnnotation = property.getDirectAnnotationUsage( LazyGroup.class );
if ( lazyGroupAnnotation != null ) { if ( lazyGroupAnnotation != null ) {
propertyBinder.setLazyGroup( lazyGroupAnnotation.getString( "value" ) ); propertyBinder.setLazyGroup( lazyGroupAnnotation.value() );
} }
final AnnotatedJoinColumns joinColumns = columnsBuilder.getJoinColumns(); final AnnotatedJoinColumns joinColumns = columnsBuilder.getJoinColumns();
@ -929,27 +951,32 @@ public class PropertyBinder {
} }
private static boolean isVersion(MemberDetails property) { private static boolean isVersion(MemberDetails property) {
return property.hasAnnotationUsage( Version.class ); return property.hasDirectAnnotationUsage( Version.class );
} }
private static boolean isOneToOne(MemberDetails property) { private static boolean isOneToOne(MemberDetails property) {
return property.hasAnnotationUsage( OneToOne.class ); return property.hasDirectAnnotationUsage( OneToOne.class );
} }
private static boolean isManyToOne(MemberDetails property) { private static boolean isManyToOne(MemberDetails property) {
return property.hasAnnotationUsage( ManyToOne.class ); return property.hasDirectAnnotationUsage( ManyToOne.class );
} }
private static boolean isAny(MemberDetails property) { private static boolean isAny(MemberDetails property) {
return property.hasAnnotationUsage( Any.class ); return property.hasDirectAnnotationUsage( Any.class );
} }
private static boolean isCollection(MemberDetails property) { private static boolean isCollection(MemberDetails property) {
return property.hasAnnotationUsage( OneToMany.class ) return property.hasDirectAnnotationUsage( OneToMany.class )
|| property.hasAnnotationUsage( ManyToMany.class ) || property.hasDirectAnnotationUsage( ManyToMany.class )
|| property.hasAnnotationUsage( ElementCollection.class ) || property.hasDirectAnnotationUsage( ElementCollection.class )
|| property.hasAnnotationUsage( ManyToAny.class ); || property.hasDirectAnnotationUsage( ManyToAny.class );
} }
private static boolean isForcePersist(MemberDetails property) {
return property.hasDirectAnnotationUsage( MapsId.class )
|| property.hasDirectAnnotationUsage( Id.class );
}
private static void bindVersionProperty( private static void bindVersionProperty(
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
@ -1267,13 +1294,13 @@ public class PropertyBinder {
* @apiNote Poorly named to a degree. The intention is really whether non-optional is explicit * @apiNote Poorly named to a degree. The intention is really whether non-optional is explicit
*/ */
private static boolean isExplicitlyOptional(MemberDetails attributeMember) { private static boolean isExplicitlyOptional(MemberDetails attributeMember) {
final AnnotationUsage<Basic> basicAnn = attributeMember.getAnnotationUsage( Basic.class ); final Basic basicAnn = attributeMember.getDirectAnnotationUsage( Basic.class );
if ( basicAnn == null ) { if ( basicAnn == null ) {
// things are optional (nullable) by default. If there is no annotation, that cannot be altered // things are optional (nullable) by default. If there is no annotation, that cannot be altered
return true; return true;
} }
return basicAnn.getBoolean( "optional" ); return basicAnn.optional();
} }
/** /**
@ -1281,9 +1308,9 @@ public class PropertyBinder {
* account whether it is primitive? * account whether it is primitive?
*/ */
public static boolean isOptional(MemberDetails attributeMember, PropertyHolder propertyHolder) { 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 ) { if ( basicAnn != null ) {
return basicAnn.getBoolean( "optional" ); return basicAnn.optional();
} }
if ( attributeMember.isArray() ) { if ( attributeMember.isArray() ) {
@ -1302,8 +1329,8 @@ public class PropertyBinder {
} }
private static boolean isLazy(MemberDetails property) { private static boolean isLazy(MemberDetails property) {
final AnnotationUsage<Basic> annotationUsage = property.getAnnotationUsage( Basic.class ); final Basic annotationUsage = property.getDirectAnnotationUsage( Basic.class );
return annotationUsage != null && annotationUsage.getEnum( "fetch" ) == LAZY; return annotationUsage != null && annotationUsage.fetch() == LAZY;
} }
private static void addIndexes( private static void addIndexes(
@ -1312,7 +1339,7 @@ public class PropertyBinder {
AnnotatedColumns columns, AnnotatedColumns columns,
AnnotatedJoinColumns joinColumns) { AnnotatedJoinColumns joinColumns) {
//process indexes after everything: in second pass, many to one has to be done before indexes //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 ) { if ( index == null ) {
return; return;
} }
@ -1341,13 +1368,12 @@ public class PropertyBinder {
// For now, simply ensure consistent naming. // For now, simply ensure consistent naming.
// TODO: AFAIK, there really isn't a reason for these UKs to be created // TODO: AFAIK, there really isn't a reason for these UKs to be created
// on the SecondPass. This whole area should go away... // 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 ) { if ( naturalId != null ) {
final Database database = context.getMetadataCollector().getDatabase(); final Database database = context.getMetadataCollector().getDatabase();
final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions().getImplicitNamingStrategy(); final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions().getImplicitNamingStrategy();
if ( joinColumns != null ) { if ( joinColumns != null ) {
final Identifier name = final Identifier name = implicitNamingStrategy.determineUniqueKeyName( new ImplicitUniqueKeyNameSource() {
implicitNamingStrategy.determineUniqueKeyName( new ImplicitUniqueKeyNameSource() {
@Override @Override
public Identifier getTableName() { public Identifier getTableName() {
return joinColumns.getTable().getNameIdentifier(); return joinColumns.getTable().getNameIdentifier();
@ -1374,8 +1400,7 @@ public class PropertyBinder {
} }
} }
else { else {
final Identifier name = final Identifier name = implicitNamingStrategy.determineUniqueKeyName(new ImplicitUniqueKeyNameSource() {
implicitNamingStrategy.determineUniqueKeyName(new ImplicitUniqueKeyNameSource() {
@Override @Override
public Identifier getTableName() { public Identifier getTableName() {
return columns.getTable().getNameIdentifier(); return columns.getTable().getNameIdentifier();
@ -1407,14 +1432,15 @@ public class PropertyBinder {
private static Class<? extends CompositeUserType<?>> resolveCompositeUserType( private static Class<? extends CompositeUserType<?>> resolveCompositeUserType(
PropertyData inferredData, PropertyData inferredData,
MetadataBuildingContext context) { MetadataBuildingContext context) {
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final MemberDetails attributeMember = inferredData.getAttributeMember(); final MemberDetails attributeMember = inferredData.getAttributeMember();
final TypeDetails classOrElementType = inferredData.getClassOrElementType(); final TypeDetails classOrElementType = inferredData.getClassOrElementType();
final ClassDetails returnedClass = classOrElementType.determineRawClass(); final ClassDetails returnedClass = classOrElementType.determineRawClass();
if ( attributeMember != null ) { if ( attributeMember != null ) {
final AnnotationUsage<CompositeType> compositeType = attributeMember.locateAnnotationUsage( CompositeType.class ); final CompositeType compositeType = attributeMember.locateAnnotationUsage( CompositeType.class, sourceModelContext );
if ( compositeType != null ) { if ( compositeType != null ) {
return compositeType.getClassDetails( "value" ).toJavaClass(); return compositeType.value();
} }
final Class<? extends CompositeUserType<?>> compositeUserType = resolveTimeZoneStorageCompositeUserType( attributeMember, returnedClass, context ); final Class<? extends CompositeUserType<?>> compositeUserType = resolveTimeZoneStorageCompositeUserType( attributeMember, returnedClass, context );
if ( compositeUserType != null ) { if ( compositeUserType != null ) {
@ -1443,24 +1469,36 @@ public class PropertyBinder {
throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData ) throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData )
+ "' belongs to an '@IdClass' and may not be annotated '@Id' or '@EmbeddedId'" ); + "' belongs to an '@IdClass' and may not be annotated '@Id' or '@EmbeddedId'" );
} }
final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final MemberDetails idAttributeMember = inferredData.getAttributeMember(); final MemberDetails idAttributeMember = inferredData.getAttributeMember();
final List<AnnotationUsage<? extends Annotation>> idGeneratorAnnotations = idAttributeMember.getMetaAnnotated( IdGeneratorType.class ); final List<? extends Annotation> idGeneratorAnnotations = idAttributeMember.getMetaAnnotated( IdGeneratorType.class, sourceModelContext );
final List<AnnotationUsage<? extends Annotation>> generatorAnnotations = idAttributeMember.getMetaAnnotated( ValueGenerationType.class ); final List<? extends Annotation> generatorAnnotations = idAttributeMember.getMetaAnnotated( ValueGenerationType.class, sourceModelContext );
removeIdGenerators( generatorAnnotations, idGeneratorAnnotations ); removeIdGenerators( generatorAnnotations, idGeneratorAnnotations );
if ( idGeneratorAnnotations.size() + generatorAnnotations.size() > 1 ) { if ( idGeneratorAnnotations.size() + generatorAnnotations.size() > 1 ) {
throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData ) throw new AnnotationException( String.format(
+ "' has too many generator annotations " + combine( idGeneratorAnnotations, generatorAnnotations ) ); Locale.ROOT,
"Property `%s` has too many generator annotations : %s",
getPath( propertyHolder, inferredData ),
CollectionHelper.combineUntyped( idGeneratorAnnotations, generatorAnnotations )
) );
} }
if ( !idGeneratorAnnotations.isEmpty() ) { if ( !idGeneratorAnnotations.isEmpty() ) {
final AnnotationUsage annotation = idGeneratorAnnotations.get(0); idValue.setCustomIdGeneratorCreator( identifierGeneratorCreator(
idValue.setCustomIdGeneratorCreator( identifierGeneratorCreator( idAttributeMember, annotation, idAttributeMember,
idValue, beanContainer( context ) ) ); idGeneratorAnnotations.get(0),
idValue,
beanContainer( context )
) );
} }
else if ( !generatorAnnotations.isEmpty() ) { else if ( !generatorAnnotations.isEmpty() ) {
// idValue.setCustomGeneratorCreator( generatorCreator( idAttributeMember, generatorAnnotation ) ); // idValue.setCustomGeneratorCreator( generatorCreator( idAttributeMember, generatorAnnotation ) );
throw new AnnotationException( "Property '"+ getPath( propertyHolder, inferredData ) throw new AnnotationException( String.format(
+ "' is annotated '" + generatorAnnotations.get(0).getAnnotationType() Locale.ROOT,
+ "' which is not an '@IdGeneratorType'" ); "Property '%s' is annotated `%s` which is not an `@IdGeneratorType`",
getPath( propertyHolder, inferredData ),
generatorAnnotations.get(0).annotationType()
) );
} }
else { else {
final ClassDetails entityClass = inferredData.getClassOrElementType().determineRawClass(); 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`. // 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 // 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: // at most one annotation for a generator:
// todo (jpa32) : is this still necessary with s/hibernate-common-annotations/hibernate-models?
private static void removeIdGenerators( private static void removeIdGenerators(
List<AnnotationUsage<? extends Annotation>> generatorAnnotations, List<? extends Annotation> generatorAnnotations,
List<AnnotationUsage<? extends Annotation>> idGeneratorAnnotations) { List<? extends Annotation> idGeneratorAnnotations) {
for ( AnnotationUsage<? extends Annotation> id : idGeneratorAnnotations ) { for ( Annotation id : idGeneratorAnnotations ) {
generatorAnnotations.removeIf( gen -> gen.getAnnotationType().equals( id.getAnnotationType() ) ); 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.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.FieldDetails; import org.hibernate.models.spi.FieldDetails;
import org.hibernate.models.spi.MemberDetails; import org.hibernate.models.spi.MemberDetails;
@ -179,9 +178,9 @@ public class PropertyContainer {
// Check fields... // Check fields...
for ( int i = 0; i < fields.size(); i++ ) { for ( int i = 0; i < fields.size(); i++ ) {
final FieldDetails fieldDetails = fields.get( 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 if ( localAccessAnnotation == null
|| localAccessAnnotation.getEnum( "value" ) != jakarta.persistence.AccessType.FIELD ) { || localAccessAnnotation.value() != jakarta.persistence.AccessType.FIELD ) {
continue; continue;
} }
persistentAttributeMap.put( fieldDetails.getName(), fieldDetails ); persistentAttributeMap.put( fieldDetails.getName(), fieldDetails );
@ -190,9 +189,9 @@ public class PropertyContainer {
// Check getters... // Check getters...
for ( int i = 0; i < getters.size(); i++ ) { for ( int i = 0; i < getters.size(); i++ ) {
final MethodDetails getterDetails = getters.get( 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 if ( localAccessAnnotation == null
|| localAccessAnnotation.getEnum( "value" ) != jakarta.persistence.AccessType.PROPERTY ) { || localAccessAnnotation.value() != jakarta.persistence.AccessType.PROPERTY ) {
continue; continue;
} }
@ -218,7 +217,7 @@ public class PropertyContainer {
// Check record components... // Check record components...
for ( int i = 0; i < recordComponents.size(); i++ ) { for ( int i = 0; i < recordComponents.size(); i++ ) {
final RecordComponentDetails componentDetails = recordComponents.get( 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 ) { if ( localAccessAnnotation == null ) {
continue; continue;
} }
@ -330,65 +329,60 @@ public class PropertyContainer {
private AccessType determineLocalClassDefinedAccessStrategy() { private AccessType determineLocalClassDefinedAccessStrategy() {
AccessType classDefinedAccessType = AccessType.DEFAULT; AccessType classDefinedAccessType = AccessType.DEFAULT;
final AnnotationUsage<Access> access = classDetails.getAnnotationUsage( Access.class ); final Access access = classDetails.getDirectAnnotationUsage( Access.class );
if ( access != null ) { if ( access != null ) {
classDefinedAccessType = AccessType.getAccessStrategy( access.getEnum( "value" ) ); classDefinedAccessType = AccessType.getAccessStrategy( access.value() );
} }
return classDefinedAccessType; return classDefinedAccessType;
} }
private static boolean discoverTypeWithoutReflection(ClassDetails classDetails, MemberDetails memberDetails) { private static boolean discoverTypeWithoutReflection(ClassDetails classDetails, MemberDetails memberDetails) {
if ( memberDetails.hasAnnotationUsage( Target.class ) ) { if ( memberDetails.hasDirectAnnotationUsage( Target.class ) ) {
return true; return true;
} }
if ( memberDetails.hasAnnotationUsage( Basic.class ) ) { if ( memberDetails.hasDirectAnnotationUsage( Basic.class ) ) {
return true; return true;
} }
if ( memberDetails.hasAnnotationUsage( Type.class ) ) { if ( memberDetails.hasDirectAnnotationUsage( Type.class ) ) {
return true; return true;
} }
if ( memberDetails.hasAnnotationUsage( JavaType.class ) ) { if ( memberDetails.hasDirectAnnotationUsage( JavaType.class ) ) {
return true; return true;
} }
final AnnotationUsage<OneToOne> oneToOneAnn = memberDetails.getAnnotationUsage( OneToOne.class ); final OneToOne oneToOneAnn = memberDetails.getDirectAnnotationUsage( OneToOne.class );
if ( oneToOneAnn != null ) { if ( oneToOneAnn != null ) {
final ClassDetails targetEntity = oneToOneAnn.getClassDetails( "targetEntity" ); return oneToOneAnn.targetEntity() != void.class;
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
} }
final OneToMany oneToManyAnn = memberDetails.getDirectAnnotationUsage( OneToMany.class );
final AnnotationUsage<OneToMany> oneToManyAnn = memberDetails.getAnnotationUsage( OneToMany.class );
if ( oneToManyAnn != null ) { if ( oneToManyAnn != null ) {
final ClassDetails targetEntity = oneToManyAnn.getClassDetails( "targetEntity" ); return oneToManyAnn.targetEntity() != void.class;
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
} }
final ManyToOne manyToOneAnn = memberDetails.getDirectAnnotationUsage( ManyToOne.class );
final AnnotationUsage<ManyToOne> manToOneAnn = memberDetails.getAnnotationUsage( ManyToOne.class ); if ( manyToOneAnn != null ) {
if ( manToOneAnn != null ) { return manyToOneAnn.targetEntity() != void.class;
final ClassDetails targetEntity = manToOneAnn.getClassDetails( "targetEntity" );
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
} }
final AnnotationUsage<ManyToMany> manToManyAnn = memberDetails.getAnnotationUsage( ManyToMany.class ); final ManyToMany manyToManyAnn = memberDetails.getDirectAnnotationUsage( ManyToMany.class );
if ( manToManyAnn != null ) { if ( manyToManyAnn != null ) {
final ClassDetails targetEntity = manToManyAnn.getClassDetails( "targetEntity" ); return manyToManyAnn.targetEntity() != void.class;
return targetEntity != ClassDetails.VOID_CLASS_DETAILS;
} }
if ( memberDetails.hasAnnotationUsage( Any.class ) ) { if ( memberDetails.hasDirectAnnotationUsage( Any.class ) ) {
return true; return true;
} }
final AnnotationUsage<ManyToAny> manToAnyAnn = memberDetails.getAnnotationUsage( ManyToAny.class ); final ManyToAny manToAnyAnn = memberDetails.getDirectAnnotationUsage( ManyToAny.class );
if ( manToAnyAnn != null ) { if ( manToAnyAnn != null ) {
return true; return true;
} }
else if ( memberDetails.hasAnnotationUsage( JdbcTypeCode.class ) ) {
if ( memberDetails.hasDirectAnnotationUsage( JdbcTypeCode.class ) ) {
return true; return true;
} }
@ -403,7 +397,7 @@ public class PropertyContainer {
private static boolean mustBeSkipped(MemberDetails memberDetails) { private static boolean mustBeSkipped(MemberDetails memberDetails) {
//TODO make those hardcoded tests more portable (through the bytecode provider?) //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() ) ); || (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; package org.hibernate.boot.model.internal;
import java.util.List;
import org.hibernate.annotations.ColumnTransformer; import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor; import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.mapping.Join; import org.hibernate.mapping.Join;
@ -15,7 +13,6 @@ import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails; 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 * 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 * 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 * 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? // todo: does this necessarily need to be a default method?
return null; return null;
} }
AnnotationUsage<ColumnTransformer> getOverriddenColumnTransformer(String logicalColumnName); ColumnTransformer getOverriddenColumnTransformer(String logicalColumnName);
/** /**
* return * return
@ -88,13 +85,13 @@ public interface PropertyHolder {
* - the join table if not overridden, * - the join table if not overridden,
* - the overridden join table otherwise * - the overridden join table otherwise
*/ */
AnnotationUsage<JoinTable> getJoinTable(MemberDetails attributeMember); JoinTable getJoinTable(MemberDetails attributeMember);
String getEntityName(); 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(); boolean isInIdClass();

View File

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

View File

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

View File

@ -7,7 +7,6 @@
package org.hibernate.boot.model.internal; package org.hibernate.boot.model.internal;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
@ -23,7 +22,6 @@ import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jpa.HibernateHints; import org.hibernate.jpa.HibernateHints;
import org.hibernate.jpa.LegacySpecHints; import org.hibernate.jpa.LegacySpecHints;
import org.hibernate.jpa.SpecHints; import org.hibernate.jpa.SpecHints;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.LockModeType; import jakarta.persistence.LockModeType;
import jakarta.persistence.NamedQuery; import jakarta.persistence.NamedQuery;
@ -38,15 +36,15 @@ public class QueryHintDefinition {
private final String queryName; private final String queryName;
private final Map<String, Object> hintsMap; 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; this.queryName = queryName;
if ( CollectionHelper.isEmpty( hints ) ) { if ( CollectionHelper.isEmpty( hints ) ) {
hintsMap = Collections.emptyMap(); hintsMap = Collections.emptyMap();
} }
else { else {
final Map<String, Object> hintsMap = mapOfSize( hints.size() ); final Map<String, Object> hintsMap = mapOfSize( hints.length );
for ( AnnotationUsage<QueryHint> hint : hints ) { for ( QueryHint hint : hints ) {
hintsMap.put( hint.getString( "name" ), hint.getString( "value" ) ); hintsMap.put( hint.name(), hint.value() );
} }
this.hintsMap = hintsMap; this.hintsMap = hintsMap;
} }
@ -153,8 +151,8 @@ public class QueryHintDefinition {
} }
} }
public LockOptions determineLockOptions(AnnotationUsage<NamedQuery> namedQueryAnnotation) { public LockOptions determineLockOptions(NamedQuery namedQueryAnnotation) {
final LockModeType lockModeType = namedQueryAnnotation.getEnum( "lockMode" ); final LockModeType lockModeType = namedQueryAnnotation.lockMode();
final Integer lockTimeoutHint = specLockTimeout(); final Integer lockTimeoutHint = specLockTimeout();
final Boolean followOnLocking = getBooleanWrapper( HibernateHints.HINT_FOLLOW_ON_LOCKING ); 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.query.SqlResultSetMappingDescriptor;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.models.spi.AnnotationUsage;
import jakarta.persistence.SqlResultSetMapping; import jakarta.persistence.SqlResultSetMapping;
@ -22,11 +21,11 @@ import jakarta.persistence.SqlResultSetMapping;
public class ResultSetMappingSecondPass implements QuerySecondPass { public class ResultSetMappingSecondPass implements QuerySecondPass {
// private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ResultsetMappingSecondPass.class ); // private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ResultsetMappingSecondPass.class );
private final AnnotationUsage<SqlResultSetMapping> annotation; private final SqlResultSetMapping annotation;
private final MetadataBuildingContext context; private final MetadataBuildingContext context;
private final boolean isDefault; 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.annotation = annotation;
this.context = context; this.context = context;
this.isDefault = isDefault; this.isDefault = isDefault;

View File

@ -13,7 +13,6 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Set; import org.hibernate.mapping.Set;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.resource.beans.spi.ManagedBean; import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.usertype.UserCollectionType; import org.hibernate.usertype.UserCollectionType;
@ -38,7 +37,7 @@ public class SetBinder extends CollectionBinder {
} }
@Override @Override
public void setSqlOrderBy(AnnotationUsage<OrderBy> orderByAnn) { public void setSqlOrderBy(OrderBy orderByAnn) {
if ( orderByAnn != null ) { if ( orderByAnn != null ) {
super.setSqlOrderBy( orderByAnn ); 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.SoftDeleteMapping;
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess; import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
import org.hibernate.metamodel.mapping.internal.SoftDeleteMappingImpl; 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.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression; 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 * 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 target The thing which is to be soft-deleted
* @param table The table to which the soft-delete should be applied * @param table The table to which the soft-delete should be applied
* @param context The processing context for access to needed info and services * @param context The processing context for access to needed info and services
*/ */
public static void bindSoftDeleteIndicator( public static void bindSoftDeleteIndicator(
AnnotationUsage<SoftDelete> softDeleteConfigAnnotation, SoftDelete softDeleteConfig,
SoftDeletable target, SoftDeletable target,
Table table, Table table,
MetadataBuildingContext context) { MetadataBuildingContext context) {
assert softDeleteConfigAnnotation != null; assert softDeleteConfig != null;
final SoftDelete softDeleteConfig = softDeleteConfigAnnotation.toAnnotation();
final BasicValue softDeleteIndicatorValue = createSoftDeleteIndicatorValue( softDeleteConfig, table, context ); final BasicValue softDeleteIndicatorValue = createSoftDeleteIndicatorValue( softDeleteConfig, table, context );
final Column softDeleteIndicatorColumn = createSoftDeleteIndicatorColumn( final Column softDeleteIndicatorColumn = createSoftDeleteIndicatorColumn(
softDeleteConfig, softDeleteConfig,

View File

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

View File

@ -11,10 +11,8 @@ import java.time.OffsetTime;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import org.hibernate.annotations.TimeZoneStorage; import org.hibernate.annotations.TimeZoneStorage;
import org.hibernate.annotations.TimeZoneStorageType;
import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.models.spi.AnnotationTarget; import org.hibernate.models.spi.AnnotationTarget;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails; import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.TypeDetails; import org.hibernate.models.spi.TypeDetails;
@ -78,7 +76,7 @@ public class TimeZoneStorageHelper {
} }
static boolean useColumnForTimeZoneStorage(AnnotationTarget element, MetadataBuildingContext context) { 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 ( timeZoneStorage == null ) {
if ( element instanceof MemberDetails attributeMember ) { if ( element instanceof MemberDetails attributeMember ) {
return isTemporalWithTimeZoneClass( attributeMember.getType().getName() ) return isTemporalWithTimeZoneClass( attributeMember.getType().getName() )
@ -90,7 +88,7 @@ public class TimeZoneStorageHelper {
} }
} }
else { else {
return switch ( timeZoneStorage.getEnum( "value", TimeZoneStorageType.class ) ) { return switch ( timeZoneStorage.value() ) {
case COLUMN -> true; case COLUMN -> true;
// if the db has native support for timezones, we use that, not a column // if the db has native support for timezones, we use that, not a column
case AUTO -> context.getBuildingOptions().getTimeZoneSupport() != NATIVE; 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.ArrayList;
import java.util.List; import java.util.List;
import jakarta.persistence.Entity;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
@ -32,11 +31,12 @@ import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne; import org.hibernate.mapping.ToOne;
import org.hibernate.models.spi.AnnotationUsage;
import org.hibernate.models.spi.ClassDetails; import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MemberDetails; import org.hibernate.models.spi.MemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey; import jakarta.persistence.ForeignKey;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -83,11 +83,11 @@ public class ToOneBinder {
MemberDetails property, MemberDetails property,
AnnotatedJoinColumns joinColumns, AnnotatedJoinColumns joinColumns,
PropertyBinder propertyBinder) { PropertyBinder propertyBinder) {
final AnnotationUsage<ManyToOne> manyToOne = property.getAnnotationUsage( ManyToOne.class ); final ManyToOne manyToOne = property.getDirectAnnotationUsage( ManyToOne.class );
//check validity //check validity
if ( property.hasAnnotationUsage( Column.class ) if ( property.hasDirectAnnotationUsage( Column.class )
|| property.hasAnnotationUsage( Columns.class ) ) { || property.hasDirectAnnotationUsage( Columns.class ) ) {
throw new AnnotationException( throw new AnnotationException(
"Property '" + getPath( propertyHolder, inferredData ) "Property '" + getPath( propertyHolder, inferredData )
+ "' is a '@ManyToOne' association and may not use '@Column' to specify column mappings (use '@JoinColumn' instead)" + "' 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 Cascade hibernateCascade = property.getDirectAnnotationUsage( Cascade.class );
final AnnotationUsage<NotFound> notFound = property.getAnnotationUsage( NotFound.class ); final NotFound notFound = property.getDirectAnnotationUsage( NotFound.class );
final NotFoundAction notFoundAction = notFound == null ? null : notFound.getEnum( "action" ); final NotFoundAction notFoundAction = notFound == null ? null : notFound.action();
matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, manyToOne.getEnum( "fetch" ) ); matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, manyToOne.fetch() );
final AnnotationUsage<OnDelete> onDelete = property.getAnnotationUsage( OnDelete.class ); final OnDelete onDelete = property.getDirectAnnotationUsage( OnDelete.class );
final AnnotationUsage<JoinTable> joinTable = propertyHolder.getJoinTable( property ); final JoinTable joinTable = propertyHolder.getJoinTable( property );
bindManyToOne( bindManyToOne(
getCascadeStrategy( manyToOne.getList( "cascade" ), hibernateCascade, false, context ), getCascadeStrategy( manyToOne.cascade(), hibernateCascade, false, context ),
joinColumns, joinColumns,
joinTable, joinTable,
!isMandatory( manyToOne.getBoolean( "optional" ), property, notFoundAction ), !isMandatory( manyToOne.optional(), property, notFoundAction ),
notFoundAction, notFoundAction,
onDelete == null ? null : onDelete.getEnum( "action" ), onDelete == null ? null : onDelete.action(),
getTargetEntity( inferredData, context ), getTargetEntity( inferredData, context ),
propertyHolder, propertyHolder,
inferredData, inferredData,
@ -144,14 +144,14 @@ public class ToOneBinder {
// the association is optional. // the association is optional.
// @OneToOne(optional = true) with @PKJC makes the association optional. // @OneToOne(optional = true) with @PKJC makes the association optional.
return !optional return !optional
|| property.hasAnnotationUsage( Id.class ) || property.hasDirectAnnotationUsage( Id.class )
|| property.hasAnnotationUsage( MapsId.class ) && notFoundAction != NotFoundAction.IGNORE; || property.hasDirectAnnotationUsage( MapsId.class ) && notFoundAction != NotFoundAction.IGNORE;
} }
private static void bindManyToOne( private static void bindManyToOne(
String cascadeStrategy, String cascadeStrategy,
AnnotatedJoinColumns joinColumns, AnnotatedJoinColumns joinColumns,
AnnotationUsage<JoinTable> joinTable, JoinTable joinTable,
boolean optional, boolean optional,
NotFoundAction notFoundAction, NotFoundAction notFoundAction,
OnDeleteAction onDeleteAction, OnDeleteAction onDeleteAction,
@ -163,7 +163,7 @@ public class ToOneBinder {
boolean inSecondPass, boolean inSecondPass,
PropertyBinder propertyBinder, PropertyBinder propertyBinder,
MetadataBuildingContext context) { MetadataBuildingContext context) {
if ( joinTable != null && !isEmpty( joinTable.getString( "name" ) ) ) { if ( joinTable != null && !isEmpty( joinTable.name() ) ) {
final Join join = propertyHolder.addJoin( joinTable, false ); final Join join = propertyHolder.addJoin( joinTable, false );
// TODO: if notFoundAction!=null should we call join.disableForeignKeyCreation() ? // TODO: if notFoundAction!=null should we call join.disableForeignKeyCreation() ?
for ( AnnotatedJoinColumn joinColumn : joinColumns.getJoinColumns() ) { for ( AnnotatedJoinColumn joinColumn : joinColumns.getJoinColumns() ) {
@ -178,7 +178,7 @@ public class ToOneBinder {
final org.hibernate.mapping.ManyToOne value = final org.hibernate.mapping.ManyToOne value =
new org.hibernate.mapping.ManyToOne( context, joinColumns.getTable() ); 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( context.getMetadataCollector().addSecondPass( new ImplicitToOneJoinTableSecondPass(
propertyHolder, propertyHolder,
inferredData, inferredData,
@ -207,15 +207,15 @@ public class ToOneBinder {
} }
} }
if ( property.hasAnnotationUsage( MapsId.class ) ) { if ( property.hasDirectAnnotationUsage( MapsId.class ) ) {
final AnnotationUsage<MapsId> mapsId = property.getAnnotationUsage( MapsId.class ); final MapsId mapsId = property.getDirectAnnotationUsage( MapsId.class );
final List<AnnotatedJoinColumn> joinColumnList = joinColumns.getJoinColumns(); final List<AnnotatedJoinColumn> joinColumnList = joinColumns.getJoinColumns();
//read only //read only
for ( AnnotatedJoinColumn column : joinColumnList ) { for ( AnnotatedJoinColumn column : joinColumnList ) {
column.setInsertable( false ); column.setInsertable( false );
column.setUpdatable( false ); column.setUpdatable( false );
} }
joinColumns.setMapsId( mapsId.getString( "value" ) ); joinColumns.setMapsId( mapsId.value() );
} }
final boolean hasSpecjManyToOne = handleSpecjSyntax( joinColumns, inferredData, context, property ); final boolean hasSpecjManyToOne = handleSpecjSyntax( joinColumns, inferredData, context, property );
@ -259,7 +259,7 @@ public class ToOneBinder {
static boolean isTargetAnnotatedEntity(ClassDetails targetEntity, MemberDetails property, MetadataBuildingContext context) { static boolean isTargetAnnotatedEntity(ClassDetails targetEntity, MemberDetails property, MetadataBuildingContext context) {
final ClassDetails target = isDefault( targetEntity, context ) ? property.getType().determineRawClass() : targetEntity; final ClassDetails target = isDefault( targetEntity, context ) ? property.getType().determineRawClass() : targetEntity;
return target.hasAnnotationUsage( Entity.class ); return target.hasDirectAnnotationUsage( Entity.class );
} }
private static boolean handleSpecjSyntax( private static boolean handleSpecjSyntax(
@ -270,18 +270,18 @@ public class ToOneBinder {
//Make sure that JPA1 key-many-to-one columns are read only too //Make sure that JPA1 key-many-to-one columns are read only too
boolean hasSpecjManyToOne = false; boolean hasSpecjManyToOne = false;
if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) { if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) {
final AnnotationUsage<JoinColumn> joinColumn = property.getAnnotationUsage( JoinColumn.class ); final JoinColumn joinColumn = property.getDirectAnnotationUsage( JoinColumn.class );
String columnName = ""; String columnName = "";
for ( MemberDetails prop : inferredData.getDeclaringClass().getFields() ) { for ( MemberDetails prop : inferredData.getDeclaringClass().getFields() ) {
if ( prop.hasAnnotationUsage( Id.class ) && prop.hasAnnotationUsage( Column.class ) ) { if ( prop.hasDirectAnnotationUsage( Id.class ) && prop.hasDirectAnnotationUsage( Column.class ) ) {
columnName = prop.getAnnotationUsage( Column.class ).getString( "name" ); columnName = prop.getDirectAnnotationUsage( Column.class ).name();
} }
if ( property.hasAnnotationUsage( ManyToOne.class ) && joinColumn != null ) { if ( property.hasDirectAnnotationUsage( ManyToOne.class ) && joinColumn != null ) {
final String joinColumnName = joinColumn.getString( "name" ); final String joinColumnName = joinColumn.name();
if ( StringHelper.isNotEmpty( joinColumnName ) if ( StringHelper.isNotEmpty( joinColumnName )
&& joinColumnName.equals( columnName ) && joinColumnName.equals( columnName )
&& !property.hasAnnotationUsage( MapsId.class ) ) { && !property.hasDirectAnnotationUsage( MapsId.class ) ) {
hasSpecjManyToOne = true; hasSpecjManyToOne = true;
for ( AnnotatedJoinColumn column : columns.getJoinColumns() ) { for ( AnnotatedJoinColumn column : columns.getJoinColumns() ) {
column.setInsertable( false ); column.setInsertable( false );
@ -326,19 +326,19 @@ public class ToOneBinder {
propertyBinder.setMemberDetails( property ); propertyBinder.setMemberDetails( property );
propertyBinder.setToMany( true ); propertyBinder.setToMany( true );
final AnnotationUsage<JoinColumn> joinColumn = property.getSingleAnnotationUsage( JoinColumn.class ); final JoinColumn joinColumn = property.getDirectAnnotationUsage( JoinColumn.class );
final AnnotationUsage<JoinColumns> joinColumns = property.getAnnotationUsage( JoinColumns.class ); final JoinColumns joinColumns = property.getDirectAnnotationUsage( JoinColumns.class );
propertyBinder.makePropertyAndBind().setOptional( optional && isNullable( joinColumns, joinColumn ) ); 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 ) { if ( joinColumn != null ) {
return joinColumn.getBoolean( "nullable" ); return joinColumn.nullable();
} }
if ( joinColumns != null ) { if ( joinColumns != null ) {
for ( AnnotationUsage<JoinColumn> column : joinColumns.<AnnotationUsage<JoinColumn>>getList( "value" ) ) { for ( JoinColumn column : joinColumns.value() ) {
if ( column.getBoolean( "nullable" ) ) { if ( column.nullable() ) {
return true; return true;
} }
} }
@ -359,7 +359,7 @@ public class ToOneBinder {
} }
private static void handleLazy(ToOne toOne, MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) { 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.setLazy( false );
toOne.setUnwrapProxy( true ); toOne.setUnwrapProxy( true );
} }
@ -378,16 +378,17 @@ public class ToOneBinder {
PropertyData inferredData) { PropertyData inferredData) {
final MetadataBuildingContext context = toOne.getBuildingContext(); final MetadataBuildingContext context = toOne.getBuildingContext();
final InFlightMetadataCollector collector = context.getMetadataCollector(); 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 ) ); collector.addSecondPass( new FetchSecondPass( usage, propertyHolder, inferredData.getPropertyName(), context ) );
} ); } );
} }
private static void handleFetch(ToOne toOne, MemberDetails property) { 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 ) { if ( fetchAnnotationUsage != null ) {
// Hibernate @Fetch annotation takes precedence // Hibernate @Fetch annotation takes precedence
setHibernateFetchMode( toOne, property, fetchAnnotationUsage.getEnum( "value" ) ); setHibernateFetchMode( toOne, property, fetchAnnotationUsage.value() );
} }
else { else {
toOne.setFetchMode( getFetchMode( getJpaFetchType( property ) ) ); toOne.setFetchMode( getFetchMode( getJpaFetchType( property ) ) );
@ -415,9 +416,9 @@ public class ToOneBinder {
private static boolean isEager(MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) { private static boolean isEager(MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) {
final FetchType fetchType = getJpaFetchType( property ); final FetchType fetchType = getJpaFetchType( property );
final AnnotationUsage<LazyToOne> lazyToOneAnnotationUsage = property.getAnnotationUsage( LazyToOne.class ); final LazyToOne lazyToOneAnnotationUsage = property.getDirectAnnotationUsage( LazyToOne.class );
if ( lazyToOneAnnotationUsage != null ) { if ( lazyToOneAnnotationUsage != null ) {
final LazyToOneOption option = lazyToOneAnnotationUsage.getEnum( "value" ); final LazyToOneOption option = lazyToOneAnnotationUsage.value();
boolean eager = option == LazyToOneOption.FALSE; boolean eager = option == LazyToOneOption.FALSE;
if ( eager && fetchType == LAZY ) { if ( eager && fetchType == LAZY ) {
// conflicts with non-default setting // conflicts with non-default setting
@ -432,13 +433,13 @@ public class ToOneBinder {
} }
private static FetchType getJpaFetchType(MemberDetails property) { private static FetchType getJpaFetchType(MemberDetails property) {
final AnnotationUsage<ManyToOne> manyToOne = property.getAnnotationUsage( ManyToOne.class ); final ManyToOne manyToOne = property.getDirectAnnotationUsage( ManyToOne.class );
final AnnotationUsage<OneToOne> oneToOne = property.getAnnotationUsage( OneToOne.class ); final OneToOne oneToOne = property.getDirectAnnotationUsage( OneToOne.class );
if ( manyToOne != null ) { if ( manyToOne != null ) {
return manyToOne.getEnum( "fetch" ); return manyToOne.fetch();
} }
else if ( oneToOne != null ) { else if ( oneToOne != null ) {
return oneToOne.getEnum( "fetch" ); return oneToOne.fetch();
} }
else { else {
throw new AssertionFailure("Define fetch strategy on a property not annotated with @OneToMany nor @OneToOne"); throw new AssertionFailure("Define fetch strategy on a property not annotated with @OneToMany nor @OneToOne");
@ -454,11 +455,11 @@ public class ToOneBinder {
MemberDetails property, MemberDetails property,
AnnotatedJoinColumns joinColumns, AnnotatedJoinColumns joinColumns,
PropertyBinder propertyBinder) { PropertyBinder propertyBinder) {
final AnnotationUsage<OneToOne> oneToOne = property.getAnnotationUsage( OneToOne.class ); final OneToOne oneToOne = property.getDirectAnnotationUsage( OneToOne.class );
//check validity //check validity
if ( property.hasAnnotationUsage( Column.class ) if ( property.hasDirectAnnotationUsage( Column.class )
|| property.hasAnnotationUsage( Columns.class ) ) { || property.hasDirectAnnotationUsage( Columns.class ) ) {
throw new AnnotationException( throw new AnnotationException(
"Property '" + getPath( propertyHolder, inferredData ) "Property '" + getPath( propertyHolder, inferredData )
+ "' is a '@OneToOne' association and may not use '@Column' to specify column mappings" + "' 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 //FIXME support a proper PKJCs
final boolean trueOneToOne = property.hasAnnotationUsage( PrimaryKeyJoinColumn.class ) final boolean trueOneToOne = property.hasDirectAnnotationUsage( PrimaryKeyJoinColumn.class )
|| property.hasAnnotationUsage( PrimaryKeyJoinColumns.class ); || property.hasDirectAnnotationUsage( PrimaryKeyJoinColumns.class );
final AnnotationUsage<Cascade> hibernateCascade = property.getAnnotationUsage( Cascade.class ); final Cascade hibernateCascade = property.getDirectAnnotationUsage( Cascade.class );
final AnnotationUsage<NotFound> notFound = property.getAnnotationUsage( NotFound.class ); final NotFound notFound = property.getDirectAnnotationUsage( NotFound.class );
final NotFoundAction notFoundAction = notFound == null ? null : notFound.getEnum( "action" ); final NotFoundAction notFoundAction = notFound == null ? null : notFound.action();
matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, oneToOne.getEnum( "fetch" ) ); matchIgnoreNotFoundWithFetchType( propertyHolder.getEntityName(), property.getName(), notFoundAction, oneToOne.fetch() );
final AnnotationUsage<OnDelete> onDelete = property.getAnnotationUsage( OnDelete.class ); final OnDelete onDelete = property.getDirectAnnotationUsage( OnDelete.class );
final AnnotationUsage<JoinTable> joinTable = propertyHolder.getJoinTable( property ); final JoinTable joinTable = propertyHolder.getJoinTable( property );
bindOneToOne( bindOneToOne(
getCascadeStrategy( oneToOne.getList( "cascade" ), hibernateCascade, oneToOne.getBoolean( "orphanRemoval" ), context ), getCascadeStrategy( oneToOne.cascade(), hibernateCascade, oneToOne.orphanRemoval(), context ),
joinColumns, joinColumns,
joinTable, joinTable,
!isMandatory( oneToOne.getBoolean( "optional" ), property, notFoundAction ), !isMandatory( oneToOne.optional(), property, notFoundAction ),
getFetchMode( oneToOne.getEnum( "fetch" ) ), getFetchMode( oneToOne.fetch() ),
notFoundAction, notFoundAction,
onDelete == null ? null : onDelete.getEnum( "action" ), onDelete == null ? null : onDelete.action(),
getTargetEntity( inferredData, context ), getTargetEntity( inferredData, context ),
property, property,
propertyHolder, propertyHolder,
inferredData, inferredData,
nullIfEmpty( oneToOne.getString( "mappedBy" ) ), nullIfEmpty( oneToOne.mappedBy() ),
trueOneToOne, trueOneToOne,
isIdentifierMapper, isIdentifierMapper,
inSecondPass, inSecondPass,
@ -507,7 +508,7 @@ public class ToOneBinder {
private static void bindOneToOne( private static void bindOneToOne(
String cascadeStrategy, String cascadeStrategy,
AnnotatedJoinColumns joinColumns, AnnotatedJoinColumns joinColumns,
AnnotationUsage<JoinTable> joinTable, JoinTable joinTable,
boolean optional, boolean optional,
FetchMode fetchMode, FetchMode fetchMode,
NotFoundAction notFoundAction, NotFoundAction notFoundAction,
@ -606,46 +607,46 @@ public class ToOneBinder {
public static void bindForeignKeyNameAndDefinition( public static void bindForeignKeyNameAndDefinition(
SimpleValue value, SimpleValue value,
MemberDetails property, MemberDetails property,
AnnotationUsage<ForeignKey> foreignKey, ForeignKey foreignKey,
MetadataBuildingContext context) { MetadataBuildingContext context) {
if ( property.hasAnnotationUsage( NotFound.class ) ) { if ( property.hasDirectAnnotationUsage( NotFound.class ) ) {
// supersedes all others // supersedes all others
value.disableForeignKey(); value.disableForeignKey();
} }
else { else {
final AnnotationUsage<JoinColumn> joinColumn = property.getSingleAnnotationUsage( JoinColumn.class ); final JoinColumn joinColumn = property.getDirectAnnotationUsage( JoinColumn.class );
final AnnotationUsage<JoinColumns> joinColumns = property.getAnnotationUsage( JoinColumns.class ); final JoinColumns joinColumns = property.getDirectAnnotationUsage( JoinColumns.class );
final boolean noConstraintByDefault = context.getBuildingOptions().isNoConstraintByDefault(); final boolean noConstraintByDefault = context.getBuildingOptions().isNoConstraintByDefault();
if ( joinColumn != null && noConstraint( joinColumn.getNestedUsage( "foreignKey" ), noConstraintByDefault ) if ( joinColumn != null && noConstraint( joinColumn.foreignKey(), noConstraintByDefault )
|| joinColumns != null && noConstraint( joinColumns.getNestedUsage( "foreignKey" ), noConstraintByDefault ) ) { || joinColumns != null && noConstraint( joinColumns.foreignKey(), noConstraintByDefault ) ) {
value.disableForeignKey(); value.disableForeignKey();
} }
else { else {
final AnnotationUsage<org.hibernate.annotations.ForeignKey> fk = final org.hibernate.annotations.ForeignKey fk =
property.getAnnotationUsage( org.hibernate.annotations.ForeignKey.class ); property.getDirectAnnotationUsage( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && isNotEmpty( fk.getString( "name" ) ) ) { if ( fk != null && isNotEmpty( fk.name() ) ) {
value.setForeignKeyName( fk.getString( "name" ) ); value.setForeignKeyName( fk.name() );
} }
else { else {
if ( noConstraint( foreignKey, noConstraintByDefault ) ) { if ( noConstraint( foreignKey, noConstraintByDefault ) ) {
value.disableForeignKey(); value.disableForeignKey();
} }
else if ( foreignKey != null ) { else if ( foreignKey != null ) {
value.setForeignKeyName( nullIfEmpty( foreignKey.getString( "name" ) ) ); value.setForeignKeyName( nullIfEmpty( foreignKey.name() ) );
value.setForeignKeyDefinition( nullIfEmpty( foreignKey.getString( "foreignKeyDefinition" ) ) ); value.setForeignKeyDefinition( nullIfEmpty( foreignKey.foreignKeyDefinition() ) );
} }
else if ( noConstraintByDefault ) { else if ( noConstraintByDefault ) {
value.disableForeignKey(); value.disableForeignKey();
} }
else if ( joinColumns != null ) { else if ( joinColumns != null ) {
final AnnotationUsage<ForeignKey> joinColumnsForeignKey = joinColumns.getNestedUsage( "foreignKey" ); final ForeignKey joinColumnsForeignKey = joinColumns.foreignKey();
value.setForeignKeyName( nullIfEmpty( joinColumnsForeignKey.getString( "name" ) ) ); value.setForeignKeyName( nullIfEmpty( joinColumnsForeignKey.name() ) );
value.setForeignKeyDefinition( nullIfEmpty( joinColumnsForeignKey.getString( "foreignKeyDefinition" ) ) ); value.setForeignKeyDefinition( nullIfEmpty( joinColumnsForeignKey.foreignKeyDefinition() ) );
} }
else if ( joinColumn != null ) { else if ( joinColumn != null ) {
final AnnotationUsage<ForeignKey> joinColumnForeignKey = joinColumn.getNestedUsage( "foreignKey" ); final ForeignKey joinColumnForeignKey = joinColumn.foreignKey();
value.setForeignKeyName( nullIfEmpty( joinColumnForeignKey.getString( "name" ) ) ); value.setForeignKeyName( nullIfEmpty( joinColumnForeignKey.name() ) );
value.setForeignKeyDefinition( nullIfEmpty( joinColumnForeignKey.getString( "foreignKeyDefinition" ) ) ); value.setForeignKeyDefinition( nullIfEmpty( joinColumnForeignKey.foreignKeyDefinition() ) );
} }
} }
} }
@ -663,17 +664,18 @@ public class ToOneBinder {
} }
public static ClassDetails getTargetEntity(PropertyData propertyData, MetadataBuildingContext context) { public static ClassDetails getTargetEntity(PropertyData propertyData, MetadataBuildingContext context) {
return getTargetEntityClass( propertyData.getAttributeMember() ); return getTargetEntityClass( propertyData.getAttributeMember(), context );
} }
private static ClassDetails getTargetEntityClass(MemberDetails property) { private static ClassDetails getTargetEntityClass(MemberDetails property, MetadataBuildingContext context) {
final AnnotationUsage<ManyToOne> manyToOne = property.getAnnotationUsage( ManyToOne.class ); final SourceModelBuildingContext sourceModelContext = context.getMetadataCollector().getSourceModelBuildingContext();
final ManyToOne manyToOne = property.getDirectAnnotationUsage( ManyToOne.class );
if ( manyToOne != null ) { 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 ) { if ( oneToOne != null ) {
return oneToOne.getClassDetails( "targetEntity" ); return sourceModelContext.getClassDetailsRegistry().resolveClassDetails( oneToOne.targetEntity().getName() );
} }
throw new AssertionFailure( "Unexpected discovery of a targetEntity: " + property.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.MappingDocument;
import org.hibernate.boot.model.source.internal.hbm.ModelBinder; import org.hibernate.boot.model.source.internal.hbm.ModelBinder;
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor; import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
import org.hibernate.boot.models.categorize.internal.DomainModelCategorizationCollector; import org.hibernate.boot.models.internal.DomainModelCategorizationCollector;
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper; import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult; import org.hibernate.boot.models.xml.spi.XmlPreProcessingResult;
import org.hibernate.boot.models.xml.spi.XmlPreProcessor; import org.hibernate.boot.models.xml.spi.XmlPreProcessor;
import org.hibernate.boot.models.xml.spi.XmlProcessingResult; import org.hibernate.boot.models.xml.spi.XmlProcessingResult;
@ -551,7 +551,7 @@ public class MetadataBuildingProcess {
//noinspection unchecked //noinspection unchecked
annotationDescriptorRegistry.resolveDescriptor( annotationDescriptorRegistry.resolveDescriptor(
annotationClass, 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 java.util.Set;
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl; 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.mapping.spi.JaxbEntityMappingsImpl;
import org.hibernate.boot.jaxb.spi.Binding;
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor; import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
import org.hibernate.boot.model.convert.spi.ConverterRegistry; import org.hibernate.boot.model.convert.spi.ConverterRegistry;
import org.hibernate.boot.model.convert.spi.RegisteredConversion; 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.ManagedResources;
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess; import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor; 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.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware; import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware;
import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.boot.spi.MetadataBuildingOptions;
@ -36,10 +34,6 @@ import org.jboss.logging.Logger;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.MappedSuperclass; 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 * @author Steve Ebersole
*/ */
@ -75,15 +69,16 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
final ConverterRegistry converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry(); final ConverterRegistry converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
domainModelSource.getConversionRegistrations().forEach( (registration) -> { domainModelSource.getConversionRegistrations().forEach( (registration) -> {
final Class<?> domainType; 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; domainType = void.class;
} }
else { else {
domainType = classLoaderService.classForName( registration.getExplicitDomainType().getClassName() ); domainType = registration.getExplicitDomainType();
} }
converterRegistry.addRegisteredConversion( new RegisteredConversion( converterRegistry.addRegisteredConversion( new RegisteredConversion(
domainType, domainType,
classLoaderService.classForName( registration.getConverterType().getClassName() ), registration.getConverterType(),
registration.isAutoApply(), registration.isAutoApply(),
rootMetadataBuildingContext rootMetadataBuildingContext
) ); ) );
@ -234,7 +229,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
List<XClass> clazzHierarchy = new ArrayList<>(); List<XClass> clazzHierarchy = new ArrayList<>();
for ( ClassDetails clazz : classes ) { for ( ClassDetails clazz : classes ) {
if ( clazz.hasAnnotationUsage( MappedSuperclass.class ) ) { if ( clazz.hasDirectAnnotationUsage( MappedSuperclass.class ) ) {
if ( debug ) { if ( debug ) {
log.debugf( log.debugf(
"Skipping explicit MappedSuperclass %s, the class will be discovered analyzing the implementing class", "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(); ClassDetails superClass = clazz.getSuperClass();
while ( superClass != null while ( superClass != null
&& !Object.class.getName().equals( superClass.getName() ) ) { && !Object.class.getName().equals( superClass.getName() ) ) {
if ( superClass.hasAnnotationUsage( Entity.class ) if ( superClass.hasDirectAnnotationUsage( Entity.class )
|| superClass.hasAnnotationUsage( MappedSuperclass.class ) ) { || superClass.hasDirectAnnotationUsage( MappedSuperclass.class ) ) {
if ( orderedClasses.contains( superClass ) ) { if ( orderedClasses.contains( superClass ) ) {
break; break;
} }

View File

@ -10,9 +10,9 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.hibernate.boot.internal.RootMappingDefaults; import org.hibernate.boot.internal.RootMappingDefaults;
import org.hibernate.boot.models.categorize.spi.ConversionRegistration; import org.hibernate.boot.models.spi.ConversionRegistration;
import org.hibernate.boot.models.categorize.spi.ConverterRegistration; import org.hibernate.boot.models.spi.ConverterRegistration;
import org.hibernate.boot.models.categorize.spi.GlobalRegistrations; import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata; import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.models.spi.ClassDetailsRegistry; 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 java.util.function.Consumer;
import org.hibernate.annotations.*; import org.hibernate.annotations.*;
import org.hibernate.boot.internal.Abstract;
import org.hibernate.boot.internal.AnyKeyType; import org.hibernate.boot.internal.AnyKeyType;
import org.hibernate.boot.internal.CollectionClassification; import org.hibernate.boot.models.annotations.internal.*;
import org.hibernate.boot.internal.Extends; import org.hibernate.boot.models.internal.OrmAnnotationHelper;
import org.hibernate.boot.internal.Target; import org.hibernate.models.internal.OrmAnnotationDescriptor;
import org.hibernate.boot.models.categorize.internal.OrmAnnotationHelper;
import org.hibernate.models.spi.AnnotationDescriptor; import org.hibernate.models.spi.AnnotationDescriptor;
import static org.hibernate.models.internal.AnnotationHelper.createOrmDescriptor;
/** /**
* Details about Hibernate annotations. * Details about Hibernate annotations.
* *
@ -33,186 +29,657 @@ import static org.hibernate.models.internal.AnnotationHelper.createOrmDescriptor
*/ */
@SuppressWarnings({ "deprecation", "removal", "unused" }) @SuppressWarnings({ "deprecation", "removal", "unused" })
public interface HibernateAnnotations { public interface HibernateAnnotations {
AnnotationDescriptor<Any> ANY = createOrmDescriptor( Any.class ); OrmAnnotationDescriptor<Any,AnyAnnotation> ANY = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<AnyDiscriminator> ANY_DISCRIMINATOR = createOrmDescriptor( AnyDiscriminator.class ); Any.class,
AnnotationDescriptor<AnyDiscriminatorValues> ANY_DISCRIMINATOR_VALUES = createOrmDescriptor( AnyDiscriminatorValues.class ); AnyAnnotation.class
AnnotationDescriptor<AnyDiscriminatorValue> ANY_DISCRIMINATOR_VALUE = createOrmDescriptor( AnyDiscriminatorValue.class, ANY_DISCRIMINATOR_VALUES ); );
AnnotationDescriptor<AnyKeyJavaClass> ANY_KEY_JAVA_CLASS = createOrmDescriptor( AnyKeyJavaClass.class ); OrmAnnotationDescriptor<AnyDiscriminator,AnyDiscriminatorAnnotation> ANY_DISCRIMINATOR = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<AnyKeyJavaType> ANY_KEY_JAVA_TYPE = createOrmDescriptor( AnyKeyJavaType.class ); AnyDiscriminator.class,
AnnotationDescriptor<AnyKeyJdbcType> ANY_KEY_JDBC_TYPE = createOrmDescriptor( AnyKeyJdbcType.class ); AnyDiscriminatorAnnotation.class
AnnotationDescriptor<AnyKeyJdbcTypeCode> ANY_KEY_JDBC_TYPE_CODE = createOrmDescriptor( AnyKeyJdbcTypeCode.class ); );
AnnotationDescriptor<AttributeAccessor> ATTRIBUTE_ACCESSOR = createOrmDescriptor( AttributeAccessor.class ); OrmAnnotationDescriptor<AnyDiscriminatorValues,AnyDiscriminatorValuesAnnotation> ANY_DISCRIMINATOR_VALUES = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<AttributeBinderType> ATTRIBUTE_BINDER_TYPE = createOrmDescriptor( AttributeBinderType.class ); AnyDiscriminatorValues.class,
AnnotationDescriptor<Bag> BAG = createOrmDescriptor( Bag.class ); AnyDiscriminatorValuesAnnotation.class
AnnotationDescriptor<BatchSize> BATCH_SIZE = createOrmDescriptor( BatchSize.class ); );
AnnotationDescriptor<Cache> CACHE = createOrmDescriptor( Cache.class ); OrmAnnotationDescriptor<AnyDiscriminatorValue,AnyDiscriminatorValueAnnotation> ANY_DISCRIMINATOR_VALUE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Cascade> CASCADE = createOrmDescriptor( Cascade.class ); AnyDiscriminatorValue.class,
AnnotationDescriptor<Checks> CHECKS = createOrmDescriptor( Checks.class ); AnyDiscriminatorValueAnnotation.class,
AnnotationDescriptor<Check> CHECK = createOrmDescriptor( Check.class, CHECKS ); ANY_DISCRIMINATOR_VALUES
AnnotationDescriptor<CollectionId> COLLECTION_ID = createOrmDescriptor( CollectionId.class ); );
AnnotationDescriptor<CollectionIdJavaType> COLLECTION_ID_JAVA_TYPE = createOrmDescriptor( CollectionIdJavaType.class ); OrmAnnotationDescriptor<AnyKeyJavaClass,AnyKeyJavaClassAnnotation> ANY_KEY_JAVA_CLASS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<CollectionIdJdbcType> COLLECTION_ID_JDBC_TYPE = createOrmDescriptor( CollectionIdJdbcType.class ); AnyKeyJavaClass.class,
AnnotationDescriptor<CollectionIdJdbcTypeCode> COLLECTION_ID_JDBC_TYPE_CODE = createOrmDescriptor( CollectionIdJdbcTypeCode.class ); AnyKeyJavaClassAnnotation.class
AnnotationDescriptor<CollectionIdMutability> COLLECTION_ID_MUTABILITY = createOrmDescriptor( CollectionIdMutability.class ); );
AnnotationDescriptor<CollectionIdType> COLLECTION_ID_TYPE = createOrmDescriptor( CollectionIdType.class ); OrmAnnotationDescriptor<AnyKeyJavaType,AnyKeyJavaTypeAnnotation> ANY_KEY_JAVA_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<CollectionType> COLLECTION_TYPE = createOrmDescriptor( CollectionType.class ); AnyKeyJavaType.class,
AnnotationDescriptor<CollectionTypeRegistrations> COLLECTION_TYPE_REGS = createOrmDescriptor( CollectionTypeRegistrations.class ); AnyKeyJavaTypeAnnotation.class
AnnotationDescriptor<CollectionTypeRegistration> COLLECTION_TYPE_REG = createOrmDescriptor( CollectionTypeRegistration.class, COLLECTION_TYPE_REGS ); );
AnnotationDescriptor<ColumnDefault> COLUMN_DEFAULT = createOrmDescriptor( ColumnDefault.class ); OrmAnnotationDescriptor<AnyKeyJdbcType,AnyKeyJdbcTypeAnnotation> ANY_KEY_JDBC_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<ColumnTransformers> COLUMN_TRANSFORMERS = createOrmDescriptor( ColumnTransformers.class ); AnyKeyJdbcType.class,
AnnotationDescriptor<ColumnTransformer> COLUMN_TRANSFORMER = createOrmDescriptor( ColumnTransformer.class, COLUMN_TRANSFORMERS ); AnyKeyJdbcTypeAnnotation.class
AnnotationDescriptor<Comment> COMMENT = createOrmDescriptor( Comment.class ); );
AnnotationDescriptor<CompositeType> COMPOSITE_TYPE = createOrmDescriptor( CompositeType.class ); OrmAnnotationDescriptor<AnyKeyJdbcTypeCode,AnyKeyJdbcTypeCodeAnnotation> ANY_KEY_JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<CompositeTypeRegistrations> COMPOSITE_TYPE_REGS = createOrmDescriptor( CompositeTypeRegistrations.class ); AnyKeyJdbcTypeCode.class,
AnnotationDescriptor<CompositeTypeRegistration> COMPOSITE_TYPE_REG = createOrmDescriptor( CompositeTypeRegistration.class, COMPOSITE_TYPE_REGS ); AnyKeyJdbcTypeCodeAnnotation.class
AnnotationDescriptor<ConverterRegistrations> CONVERTER_REGS = createOrmDescriptor( ConverterRegistrations.class ); );
AnnotationDescriptor<ConverterRegistration> CONVERTER_REG = createOrmDescriptor( ConverterRegistration.class, CONVERTER_REGS ); OrmAnnotationDescriptor<AnyKeyType, AnyKeTypeAnnotation> ANY_KEY_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<CreationTimestamp> CREATION_TIMESTAMP = createOrmDescriptor( CreationTimestamp.class ); AnyKeyType.class,
AnnotationDescriptor<CurrentTimestamp> CURRENT_TIMESTAMP = createOrmDescriptor( CurrentTimestamp.class ); AnyKeTypeAnnotation.class
AnnotationDescriptor<DiscriminatorFormula> DISCRIMINATOR_FORMULA = createOrmDescriptor( DiscriminatorFormula.class ); );
AnnotationDescriptor<DiscriminatorOptions> DISCRIMINATOR_OPTIONS = createOrmDescriptor( DiscriminatorOptions.class ); OrmAnnotationDescriptor<Array,ArrayAnnotation> ARRAY = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DynamicInsert> DYNAMIC_INSERT = createOrmDescriptor( DynamicInsert.class ); Array.class,
AnnotationDescriptor<DynamicUpdate> DYNAMIC_UPDATE = createOrmDescriptor( DynamicUpdate.class ); ArrayAnnotation.class
AnnotationDescriptor<EmbeddableInstantiator> EMBEDDABLE_INSTANTIATOR = createOrmDescriptor( EmbeddableInstantiator.class ); );
AnnotationDescriptor<EmbeddableInstantiatorRegistrations> EMBEDDABLE_INSTANTIATOR_REGS = createOrmDescriptor( EmbeddableInstantiatorRegistrations.class ); SpecializedAnnotationDescriptor<AttributeAccessor,AttributeAccessorAnnotation> ATTRIBUTE_ACCESSOR = new SpecializedAnnotationDescriptor<>(
AnnotationDescriptor<EmbeddableInstantiatorRegistration> EMBEDDABLE_INSTANTIATOR_REG = createOrmDescriptor( EmbeddableInstantiatorRegistration.class, EMBEDDABLE_INSTANTIATOR_REGS ); AttributeAccessor.class,
AnnotationDescriptor<Fetch> FETCH = createOrmDescriptor( Fetch.class ); AttributeAccessorAnnotation.class
AnnotationDescriptor<FetchProfiles> FETCH_PROFILES = createOrmDescriptor( FetchProfiles.class ); );
AnnotationDescriptor<FetchProfile> FETCH_PROFILE = createOrmDescriptor( FetchProfile.class, FETCH_PROFILES ); OrmAnnotationDescriptor<AttributeBinderType,AttributeBinderTypeAnnotation> ATTRIBUTE_BINDER_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Filters> FILTERS = createOrmDescriptor( Filters.class ); AttributeBinderType.class,
AnnotationDescriptor<Filter> FILTER = createOrmDescriptor( Filter.class, FILTERS ); AttributeBinderTypeAnnotation.class
AnnotationDescriptor<FilterDefs> FILTER_DEFS = createOrmDescriptor( FilterDefs.class ); );
AnnotationDescriptor<FilterDef> FILTER_DEF = createOrmDescriptor( FilterDef.class, FILTER_DEFS ); OrmAnnotationDescriptor<Bag,BagAnnotation> BAG = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<FilterJoinTables> FILTER_JOIN_TABLES = createOrmDescriptor( FilterJoinTables.class ); Bag.class,
AnnotationDescriptor<FilterJoinTable> FILTER_JOIN_TABLE = createOrmDescriptor( FilterJoinTable.class, FILTER_JOIN_TABLES ); BagAnnotation.class
AnnotationDescriptor<ForeignKey> FOREIGN_KEY = createOrmDescriptor( ForeignKey.class ); );
AnnotationDescriptor<Formula> FORMULA = createOrmDescriptor( Formula.class ); SpecializedAnnotationDescriptor<BatchSize,BatchSizeAnnotation> BATCH_SIZE = new SpecializedAnnotationDescriptor<>(
AnnotationDescriptor<Generated> GENERATED = createOrmDescriptor( Generated.class ); BatchSize.class,
AnnotationDescriptor<GeneratedColumn> GENERATED_COLUMN = createOrmDescriptor( GeneratedColumn.class ); BatchSizeAnnotation.class
AnnotationDescriptor<GeneratorType> GENERATOR_TYPE = createOrmDescriptor( GeneratorType.class ); );
AnnotationDescriptor<GenericGenerators> GENERIC_GENERATORS = createOrmDescriptor( GenericGenerators.class ); OrmAnnotationDescriptor<Cache,CacheAnnotation> CACHE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<GenericGenerator> GENERIC_GENERATOR = createOrmDescriptor( GenericGenerator.class, GENERIC_GENERATORS ); Cache.class,
AnnotationDescriptor<IdGeneratorType> ID_GENERATOR_TYPE = createOrmDescriptor( IdGeneratorType.class ); CacheAnnotation.class
AnnotationDescriptor<Immutable> IMMUTABLE = createOrmDescriptor( Immutable.class ); );
AnnotationDescriptor<Imported> IMPORTED = createOrmDescriptor( Imported.class ); OrmAnnotationDescriptor<Cascade,CascadeAnnotation> CASCADE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Index> INDEX = createOrmDescriptor( Index.class ); Cascade.class,
AnnotationDescriptor<IndexColumn> INDEX_COLUMN = createOrmDescriptor( IndexColumn.class ); CascadeAnnotation.class
AnnotationDescriptor<Instantiator> INSTANTIATOR = createOrmDescriptor( Instantiator.class ); );
AnnotationDescriptor<JavaType> JAVA_TYPE = createOrmDescriptor( JavaType.class ); OrmAnnotationDescriptor<Checks,ChecksAnnotation> CHECKS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<JavaTypeRegistrations> JAVA_TYPE_REGS = createOrmDescriptor( JavaTypeRegistrations.class ); Checks.class,
AnnotationDescriptor<JavaTypeRegistration> JAVA_TYPE_REG = createOrmDescriptor( JavaTypeRegistration.class, JAVA_TYPE_REGS ); ChecksAnnotation.class
AnnotationDescriptor<JdbcType> JDBC_TYPE = createOrmDescriptor( JdbcType.class ); );
AnnotationDescriptor<JdbcTypeCode> JDBC_TYPE_CODE = createOrmDescriptor( JdbcTypeCode.class ); OrmAnnotationDescriptor<Check,CheckAnnotation> CHECK = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<JdbcTypeRegistrations> JDBC_TYPE_REGS = createOrmDescriptor( JdbcTypeRegistrations.class ); Check.class,
AnnotationDescriptor<JdbcTypeRegistration> JDBC_TYPE_REG = createOrmDescriptor( JdbcTypeRegistration.class, JDBC_TYPE_REGS ); CheckAnnotation.class,
AnnotationDescriptor<JoinColumnsOrFormulas> JOIN_COLUMNS_OR_FORMULAS = createOrmDescriptor( JoinColumnsOrFormulas.class ); CHECKS
AnnotationDescriptor<JoinColumnOrFormula> JOIN_COLUMN_OR_FORMULA = createOrmDescriptor( JoinColumnOrFormula.class, JOIN_COLUMNS_OR_FORMULAS ); );
AnnotationDescriptor<JoinFormula> JOIN_FORMULA = createOrmDescriptor( JoinFormula.class ); SpecializedAnnotationDescriptor<Collate,CollateAnnotation> COLLATE = new SpecializedAnnotationDescriptor<>(
AnnotationDescriptor<LazyCollection> LAZY_COLLECTION = createOrmDescriptor( LazyCollection.class ); Collate.class,
AnnotationDescriptor<LazyGroup> LAZY_GROUP = createOrmDescriptor( LazyGroup.class ); CollateAnnotation.class
AnnotationDescriptor<LazyToOne> LAZY_TO_ONE = createOrmDescriptor( LazyToOne.class ); );
AnnotationDescriptor<ListIndexBase> LIST_INDEX_BASE = createOrmDescriptor( ListIndexBase.class ); OrmAnnotationDescriptor<CollectionId,CollectionIdAnnotation> COLLECTION_ID = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<ListIndexJavaType> LIST_INDEX_JAVA_TYPE = createOrmDescriptor( ListIndexJavaType.class ); CollectionId.class,
AnnotationDescriptor<ListIndexJdbcType> LIST_INDEX_JDBC_TYPE = createOrmDescriptor( ListIndexJdbcType.class ); CollectionIdAnnotation.class
AnnotationDescriptor<ListIndexJdbcTypeCode> LIST_INDEX_JDBC_TYPE_CODE = createOrmDescriptor( ListIndexJdbcTypeCode.class ); );
AnnotationDescriptor<Loader> LOADER = createOrmDescriptor( Loader.class ); OrmAnnotationDescriptor<CollectionIdJavaType,CollectionIdJavaTypeAnnotation> COLLECTION_ID_JAVA_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<ManyToAny> MANY_TO_ANY = createOrmDescriptor( ManyToAny.class ); CollectionIdJavaType.class,
AnnotationDescriptor<MapKeyCompositeType> MAP_KEY_COMPOSITE_TYPE = createOrmDescriptor( MapKeyCompositeType.class ); CollectionIdJavaTypeAnnotation.class
AnnotationDescriptor<MapKeyJavaType> MAP_KEY_JAVA_TYPE = createOrmDescriptor( MapKeyJavaType.class ); );
AnnotationDescriptor<MapKeyJdbcType> MAP_KEY_JDBC_TYPE = createOrmDescriptor( MapKeyJdbcType.class ); OrmAnnotationDescriptor<CollectionIdJdbcType,CollectionIdJdbcTypeAnnotation> COLLECTION_ID_JDBC_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<MapKeyJdbcTypeCode> MAP_KEY_JDBC_TYPE_CODE = createOrmDescriptor( MapKeyJdbcTypeCode.class ); CollectionIdJdbcType.class,
AnnotationDescriptor<MapKeyMutability> MAP_KEY_MUTABILITY = createOrmDescriptor( MapKeyMutability.class ); CollectionIdJdbcTypeAnnotation.class
AnnotationDescriptor<MapKeyType> MAP_KEY_TYPE = createOrmDescriptor( MapKeyType.class ); );
AnnotationDescriptor<Mutability> MUTABILITY = createOrmDescriptor( Mutability.class ); OrmAnnotationDescriptor<CollectionIdJdbcTypeCode,CollectionIdJdbcTypeCodeAnnotation> COLLECTION_ID_JDBC_TYPE_CODE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<NamedNativeQueries> NAMED_NATIVE_QUERIES = createOrmDescriptor( NamedNativeQueries.class ); CollectionIdJdbcTypeCode.class,
AnnotationDescriptor<NamedNativeQuery> NAMED_NATIVE_QUERY = createOrmDescriptor( NamedNativeQuery.class, NAMED_NATIVE_QUERIES ); CollectionIdJdbcTypeCodeAnnotation.class
AnnotationDescriptor<NamedQueries> NAMED_QUERIES = createOrmDescriptor( NamedQueries.class ); );
AnnotationDescriptor<NamedQuery> NAMED_QUERY = createOrmDescriptor( NamedQuery.class, NAMED_QUERIES ); OrmAnnotationDescriptor<CollectionIdMutability,CollectionIdMutabilityAnnotation> COLLECTION_ID_MUTABILITY = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Nationalized> NATIONALIZED = createOrmDescriptor( Nationalized.class ); CollectionIdMutability.class,
AnnotationDescriptor<NaturalId> NATURAL_ID = createOrmDescriptor( NaturalId.class ); CollectionIdMutabilityAnnotation.class
AnnotationDescriptor<NaturalIdCache> NATURAL_ID_CACHE = createOrmDescriptor( NaturalIdCache.class ); );
AnnotationDescriptor<NotFound> NOT_FOUND = createOrmDescriptor( NotFound.class ); OrmAnnotationDescriptor<CollectionIdType,CollectionIdTypeAnnotation> COLLECTION_ID_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<OnDelete> ON_DELETE = createOrmDescriptor( OnDelete.class ); CollectionIdType.class,
AnnotationDescriptor<OptimisticLock> OPTIMISTIC_LOCK = createOrmDescriptor( OptimisticLock.class ); CollectionIdTypeAnnotation.class
AnnotationDescriptor<OptimisticLocking> OPTIMISTIC_LOCKING = createOrmDescriptor( OptimisticLocking.class ); );
AnnotationDescriptor<OrderBy> ORDER_BY = createOrmDescriptor( OrderBy.class ); OrmAnnotationDescriptor<CollectionType,CollectionTypeAnnotation> COLLECTION_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<ParamDef> PARAM_DEF = createOrmDescriptor( ParamDef.class ); CollectionType.class,
AnnotationDescriptor<Parameter> PARAMETER = createOrmDescriptor( Parameter.class ); CollectionTypeAnnotation.class
AnnotationDescriptor<Parent> PARENT = createOrmDescriptor( Parent.class ); );
AnnotationDescriptor<PartitionKey> PARTITION_KEY = createOrmDescriptor( PartitionKey.class ); OrmAnnotationDescriptor<CollectionTypeRegistrations,CollectionTypeRegistrationsAnnotation> COLLECTION_TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Polymorphism> POLYMORPHISM = createOrmDescriptor( Polymorphism.class ); CollectionTypeRegistrations.class,
AnnotationDescriptor<Proxy> PROXY = createOrmDescriptor( Proxy.class ); CollectionTypeRegistrationsAnnotation.class
AnnotationDescriptor<RowId> ROW_ID = createOrmDescriptor( RowId.class ); );
AnnotationDescriptor<SecondaryRows> SECONDARY_ROWS = createOrmDescriptor( SecondaryRows.class ); OrmAnnotationDescriptor<CollectionTypeRegistration,CollectionTypeRegistrationAnnotation> COLLECTION_TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<SecondaryRow> SECONDARY_ROW = createOrmDescriptor( SecondaryRow.class, SECONDARY_ROWS ); CollectionTypeRegistration.class,
AnnotationDescriptor<SelectBeforeUpdate> SELECT_BEFORE_UPDATE = createOrmDescriptor( SelectBeforeUpdate.class ); CollectionTypeRegistrationAnnotation.class,
AnnotationDescriptor<SortComparator> SORT_COMPARATOR = createOrmDescriptor( SortComparator.class ); COLLECTION_TYPE_REGISTRATIONS
AnnotationDescriptor<SortNatural> SORT_NATURAL = createOrmDescriptor( SortNatural.class ); );
AnnotationDescriptor<Source> SOURCE = createOrmDescriptor( Source.class ); OrmAnnotationDescriptor<ColumnDefault,ColumnDefaultAnnotation> COLUMN_DEFAULT = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<SQLDeletes> SQL_DELETES = createOrmDescriptor( SQLDeletes.class ); ColumnDefault.class,
AnnotationDescriptor<SQLDelete> SQL_DELETE = createOrmDescriptor( SQLDelete.class, SQL_DELETES ); ColumnDefaultAnnotation.class
AnnotationDescriptor<SQLDeleteAll> SQL_DELETE_ALL = createOrmDescriptor( SQLDeleteAll.class ); );
AnnotationDescriptor<SqlFragmentAlias> SQL_FRAGMENT_ALIAS = createOrmDescriptor( SqlFragmentAlias.class ); OrmAnnotationDescriptor<Columns,ColumnsAnnotation> COLUMNS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<SQLInserts> SQL_INSERTS = createOrmDescriptor( SQLInserts.class ); Columns.class,
AnnotationDescriptor<SQLInsert> SQL_INSERT = createOrmDescriptor( SQLInsert.class, SQL_INSERTS ); ColumnsAnnotation.class
AnnotationDescriptor<SQLRestriction> SQL_RESTRICTION = createOrmDescriptor( SQLRestriction.class, SQL_INSERTS ); );
AnnotationDescriptor<SQLJoinTableRestriction> SQL_RESTRICTION_JOIN_TABLE = createOrmDescriptor( SQLJoinTableRestriction.class, SQL_INSERTS ); OrmAnnotationDescriptor<ColumnTransformers,ColumnTransformersAnnotation> COLUMN_TRANSFORMERS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<SQLUpdates> SQL_UPDATES = createOrmDescriptor( SQLUpdates.class ); ColumnTransformers.class,
AnnotationDescriptor<SQLUpdate> SQL_UPDATE = createOrmDescriptor( SQLUpdate.class, SQL_UPDATES ); ColumnTransformersAnnotation.class
AnnotationDescriptor<Struct> STRUCT = createOrmDescriptor( Struct.class ); );
AnnotationDescriptor<Subselect> SUBSELECT = createOrmDescriptor( Subselect.class ); OrmAnnotationDescriptor<ColumnTransformer,ColumnTransformerAnnotation> COLUMN_TRANSFORMER = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Synchronize> SYNCHRONIZE = createOrmDescriptor( Synchronize.class ); ColumnTransformer.class,
AnnotationDescriptor<Tables> TABLES = createOrmDescriptor( Tables.class ); ColumnTransformerAnnotation.class,
AnnotationDescriptor<Table> TABLE = createOrmDescriptor( Table.class, TABLES ); COLUMN_TRANSFORMERS
AnnotationDescriptor<TenantId> TENANT_ID = createOrmDescriptor( TenantId.class ); );
AnnotationDescriptor<TimeZoneColumn> TZ_COLUMN = createOrmDescriptor( TimeZoneColumn.class ); SpecializedAnnotationDescriptor<Comments,CommentsAnnotation> COMMENTS = new SpecializedAnnotationDescriptor<>(
AnnotationDescriptor<TimeZoneStorage> TZ_STORAGE = createOrmDescriptor( TimeZoneStorage.class ); Comments.class,
AnnotationDescriptor<Type> TYPE = createOrmDescriptor( Type.class ); CommentsAnnotation.class
AnnotationDescriptor<TypeBinderType> TYPE_BINDER_TYPE = createOrmDescriptor( TypeBinderType.class ); );
AnnotationDescriptor<TypeRegistrations> TYPE_REGS = createOrmDescriptor( TypeRegistrations.class ); SpecializedAnnotationDescriptor<Comment,CommentAnnotation> COMMENT = new SpecializedAnnotationDescriptor<>(
AnnotationDescriptor<TypeRegistration> TYPE_REG = createOrmDescriptor( TypeRegistration.class, TYPE_REGS ); Comment.class,
AnnotationDescriptor<UpdateTimestamp> UPDATE_TIMESTAMP = createOrmDescriptor( UpdateTimestamp.class ); CommentAnnotation.class,
AnnotationDescriptor<UuidGenerator> UUID_GENERATOR = createOrmDescriptor( UuidGenerator.class ); COMMENTS
AnnotationDescriptor<ValueGenerationType> VALUE_GENERATION_TYPE = createOrmDescriptor( ValueGenerationType.class ); );
AnnotationDescriptor<Where> WHERE = createOrmDescriptor( Where.class ); OrmAnnotationDescriptor<CompositeType,CompositeTypeAnnotation> COMPOSITE_TYPE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<WhereJoinTable> WHERE_JOIN_TABLE = createOrmDescriptor( WhereJoinTable.class ); CompositeType.class,
CompositeTypeAnnotation.class
AnnotationDescriptor<Abstract> ABSTRACT = createOrmDescriptor( Abstract.class ); );
AnnotationDescriptor<AnyKeyType> ANY_KEY_TYPE = createOrmDescriptor( AnyKeyType.class ); OrmAnnotationDescriptor<CompositeTypeRegistrations,CompositeTypeRegistrationsAnnotation> COMPOSITE_TYPE_REGISTRATIONS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<CollectionClassification> COLLECTION_CLASSIFICATION = createOrmDescriptor( CollectionClassification.class ); CompositeTypeRegistrations.class,
AnnotationDescriptor<Extends> EXTENDS = createOrmDescriptor( Extends.class ); CompositeTypeRegistrationsAnnotation.class
AnnotationDescriptor<Target> TARGET = createOrmDescriptor( Target.class ); );
OrmAnnotationDescriptor<CompositeTypeRegistration,CompositeTypeRegistrationAnnotation> COMPOSITE_TYPE_REGISTRATION = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.Checks> DIALECT_OVERRIDE_CHECKS = createOrmDescriptor( DialectOverride.Checks.class ); CompositeTypeRegistration.class,
AnnotationDescriptor<DialectOverride.Check> DIALECT_OVERRIDE_CHECK = createOrmDescriptor( DialectOverride.Check.class, DIALECT_OVERRIDE_CHECKS ); CompositeTypeRegistrationAnnotation.class,
AnnotationDescriptor<DialectOverride.OrderBys> DIALECT_OVERRIDE_ORDER_BYS = createOrmDescriptor( DialectOverride.OrderBys.class ); COMPOSITE_TYPE_REGISTRATIONS
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 ); OrmAnnotationDescriptor<ConcreteProxy,ConcreteProxyAnnotation> CONCRETE_PROXY = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.ColumnDefault> DIALECT_OVERRIDE_COLUMN_DEFAULT = createOrmDescriptor( DialectOverride.ColumnDefault.class, DIALECT_OVERRIDE_COLUMN_DEFAULTS ); ConcreteProxy.class,
AnnotationDescriptor<DialectOverride.GeneratedColumns> DIALECT_OVERRIDE_GENERATED_COLUMNS = createOrmDescriptor( DialectOverride.GeneratedColumns.class ); ConcreteProxyAnnotation.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 ); OrmAnnotationDescriptor<ConverterRegistrations,ConverterRegistrationsAnnotation> CONVERTER_REGISTRATIONS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.DiscriminatorFormula> DIALECT_OVERRIDE_DISCRIMINATOR_FORMULA = createOrmDescriptor( DialectOverride.DiscriminatorFormula.class, DIALECT_OVERRIDE_DISCRIMINATOR_FORMULAS ); ConverterRegistrations.class,
AnnotationDescriptor<DialectOverride.Formulas> DIALECT_OVERRIDE_FORMULAS = createOrmDescriptor( DialectOverride.Formulas.class ); ConverterRegistrationsAnnotation.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 ); OrmAnnotationDescriptor<ConverterRegistration,ConverterRegistrationAnnotation> CONVERTER_REGISTRATION = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.JoinFormula> DIALECT_OVERRIDE_JOIN_FORMULA = createOrmDescriptor( DialectOverride.JoinFormula.class, DIALECT_OVERRIDE_JOIN_FORMULAS ); ConverterRegistration.class,
AnnotationDescriptor<DialectOverride.Wheres> DIALECT_OVERRIDE_WHERES = createOrmDescriptor( DialectOverride.Wheres.class ); ConverterRegistrationAnnotation.class,
AnnotationDescriptor<DialectOverride.Where> DIALECT_OVERRIDE_WHERE = createOrmDescriptor( DialectOverride.Where.class, DIALECT_OVERRIDE_WHERES ); CONVERTER_REGISTRATIONS
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 ); OrmAnnotationDescriptor<CreationTimestamp,CreationTimestampAnnotation> CREATION_TIMESTAMP = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.FilterDefOverrides> DIALECT_OVERRIDE_FILTER_DEF_OVERRIDES = createOrmDescriptor( DialectOverride.FilterDefOverrides.class ); CreationTimestamp.class,
AnnotationDescriptor<DialectOverride.FilterDefs> DIALECT_OVERRIDE_FILTER_DEFS = createOrmDescriptor( DialectOverride.FilterDefs.class, DIALECT_OVERRIDE_FILTER_DEF_OVERRIDES ); CreationTimestampAnnotation.class
AnnotationDescriptor<DialectOverride.Version> DIALECT_OVERRIDE_VERSION = createOrmDescriptor( DialectOverride.Version.class ); );
OrmAnnotationDescriptor<CurrentTimestamp,CurrentTimestampAnnotation> CURRENT_TIMESTAMP = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.SQLInserts> DIALECT_OVERRIDE_SQL_INSERTS = createOrmDescriptor( DialectOverride.SQLInserts.class ); CurrentTimestamp.class,
AnnotationDescriptor<DialectOverride.SQLInsert> DIALECT_OVERRIDE_SQL_INSERT = createOrmDescriptor( DialectOverride.SQLInsert.class, DIALECT_OVERRIDE_SQL_INSERTS ); CurrentTimestampAnnotation.class
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 ); OrmAnnotationDescriptor<DiscriminatorFormula,DiscriminatorFormulaAnnotation> DISCRIMINATOR_FORMULA = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DialectOverride.SQLDeletes> DIALECT_OVERRIDE_SQL_DELETES = createOrmDescriptor( DialectOverride.SQLDeletes.class ); DiscriminatorFormula.class,
AnnotationDescriptor<DialectOverride.SQLDelete> DIALECT_OVERRIDE_SQL_DELETE = createOrmDescriptor( DialectOverride.SQLDelete.class, DIALECT_OVERRIDE_SQL_DELETES ); DiscriminatorFormulaAnnotation.class
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 ); 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) { static void forEachAnnotation(Consumer<AnnotationDescriptor<? extends Annotation>> consumer) {
OrmAnnotationHelper.forEachOrmAnnotation( HibernateAnnotations.class, consumer ); OrmAnnotationHelper.forEachOrmAnnotation( HibernateAnnotations.class, consumer );

View File

@ -9,7 +9,96 @@ package org.hibernate.boot.models;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.function.Consumer; 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 org.hibernate.models.spi.AnnotationDescriptor;
import jakarta.persistence.Access; import jakarta.persistence.Access;
@ -37,6 +126,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners; import jakarta.persistence.EntityListeners;
import jakarta.persistence.EntityResult; import jakarta.persistence.EntityResult;
import jakarta.persistence.Enumerated; import jakarta.persistence.Enumerated;
import jakarta.persistence.EnumeratedValue;
import jakarta.persistence.ExcludeDefaultListeners; import jakarta.persistence.ExcludeDefaultListeners;
import jakarta.persistence.ExcludeSuperclassListeners; import jakarta.persistence.ExcludeSuperclassListeners;
import jakarta.persistence.FieldResult; import jakarta.persistence.FieldResult;
@ -100,101 +190,379 @@ import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version; import jakarta.persistence.Version;
import static org.hibernate.models.internal.AnnotationHelper.createOrmDescriptor;
/** /**
* Descriptors for JPA annotations * Descriptors for JPA annotations
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface JpaAnnotations { public interface JpaAnnotations {
AnnotationDescriptor<Access> ACCESS = createOrmDescriptor( Access.class ); OrmAnnotationDescriptor<Access,AccessJpaAnnotation> ACCESS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<AssociationOverrides> ASSOCIATION_OVERRIDES = createOrmDescriptor( AssociationOverrides.class ); Access.class,
AnnotationDescriptor<AssociationOverride> ASSOCIATION_OVERRIDE = createOrmDescriptor( AssociationOverride.class, ASSOCIATION_OVERRIDES ); AccessJpaAnnotation.class
AnnotationDescriptor<AttributeOverrides> ATTRIBUTE_OVERRIDES = createOrmDescriptor( AttributeOverrides.class ); );
AnnotationDescriptor<AttributeOverride> ATTRIBUTE_OVERRIDE = createOrmDescriptor( AttributeOverride.class, ATTRIBUTE_OVERRIDES );
AnnotationDescriptor<Basic> BASIC = createOrmDescriptor( Basic.class ); OrmAnnotationDescriptor<AssociationOverrides,AssociationOverridesJpaAnnotation> ASSOCIATION_OVERRIDES = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Cacheable> CACHEABLE = createOrmDescriptor( Cacheable.class ); AssociationOverrides.class,
AnnotationDescriptor<CheckConstraint> CHECK_CONSTRAINT = createOrmDescriptor(CheckConstraint.class ); AssociationOverridesJpaAnnotation.class
AnnotationDescriptor<CollectionTable> COLLECTION_TABLE = createOrmDescriptor( CollectionTable.class ); );
AnnotationDescriptor<Column> COLUMN = createOrmDescriptor( Column.class ); OrmAnnotationDescriptor<AssociationOverride,AssociationOverrideJpaAnnotation> ASSOCIATION_OVERRIDE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<ColumnResult> COLUMN_RESULT = createOrmDescriptor( ColumnResult.class ); AssociationOverride.class,
AnnotationDescriptor<ConstructorResult> CONSTRUCTOR_RESULT = createOrmDescriptor( ConstructorResult.class ); AssociationOverrideJpaAnnotation.class,
AnnotationDescriptor<Converts> CONVERTS = createOrmDescriptor( Converts.class ); ASSOCIATION_OVERRIDES
AnnotationDescriptor<Convert> CONVERT = createOrmDescriptor( Convert.class, CONVERTS ); );
AnnotationDescriptor<Converter> CONVERTER = createOrmDescriptor( Converter.class ); OrmAnnotationDescriptor<AttributeOverrides,AttributeOverridesJpaAnnotation> ATTRIBUTE_OVERRIDES = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<DiscriminatorColumn> DISCRIMINATOR_COLUMN = createOrmDescriptor( DiscriminatorColumn.class ); AttributeOverrides.class,
AnnotationDescriptor<DiscriminatorValue> DISCRIMINATOR_VALUE = createOrmDescriptor( DiscriminatorValue.class ); AttributeOverridesJpaAnnotation.class
AnnotationDescriptor<ElementCollection> ELEMENT_COLLECTION = createOrmDescriptor( ElementCollection.class ); );
AnnotationDescriptor<Embeddable> EMBEDDABLE = createOrmDescriptor( Embeddable.class ); OrmAnnotationDescriptor<AttributeOverride,AttributeOverrideJpaAnnotation> ATTRIBUTE_OVERRIDE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Embedded> EMBEDDED = createOrmDescriptor( Embedded.class ); AttributeOverride.class,
AnnotationDescriptor<EmbeddedId> EMBEDDED_ID = createOrmDescriptor( EmbeddedId.class ); AttributeOverrideJpaAnnotation.class,
AnnotationDescriptor<Entity> ENTITY = createOrmDescriptor( Entity.class ); ATTRIBUTE_OVERRIDES
AnnotationDescriptor<EntityListeners> ENTITY_LISTENERS = createOrmDescriptor( EntityListeners.class ); );
AnnotationDescriptor<EntityResult> ENTITY_RESULT = createOrmDescriptor( EntityResult.class ); OrmAnnotationDescriptor<Basic,BasicJpaAnnotation> BASIC = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Enumerated> ENUMERATED = createOrmDescriptor( Enumerated.class ); Basic.class,
AnnotationDescriptor<ExcludeDefaultListeners> EXCLUDE_DEFAULT_LISTENERS = createOrmDescriptor( ExcludeDefaultListeners.class ); BasicJpaAnnotation.class
AnnotationDescriptor<ExcludeSuperclassListeners> EXCLUDE_SUPERCLASS_LISTENERS = createOrmDescriptor( ExcludeSuperclassListeners.class ); );
AnnotationDescriptor<FieldResult> FIELD_RESULT = createOrmDescriptor( FieldResult.class ); OrmAnnotationDescriptor<Cacheable,CacheableJpaAnnotation> CACHEABLE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<ForeignKey> FOREIGN_KEY = createOrmDescriptor( ForeignKey.class ); Cacheable.class,
AnnotationDescriptor<GeneratedValue> GENERATED_VALUE = createOrmDescriptor( GeneratedValue.class ); CacheableJpaAnnotation.class
AnnotationDescriptor<Id> ID = createOrmDescriptor( Id.class ); );
AnnotationDescriptor<IdClass> ID_CLASS = createOrmDescriptor( IdClass.class ); OrmAnnotationDescriptor<CheckConstraint,CheckConstraintJpaAnnotation> CHECK_CONSTRAINT = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<Index> INDEX = createOrmDescriptor( Index.class ); CheckConstraint.class,
AnnotationDescriptor<Inheritance> INHERITANCE = createOrmDescriptor( Inheritance.class ); CheckConstraintJpaAnnotation.class
AnnotationDescriptor<JoinColumns> JOIN_COLUMNS = createOrmDescriptor( JoinColumns.class ); );
AnnotationDescriptor<JoinColumn> JOIN_COLUMN = createOrmDescriptor( JoinColumn.class, JOIN_COLUMNS ); OrmAnnotationDescriptor<CollectionTable,CollectionTableJpaAnnotation> COLLECTION_TABLE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<JoinTable> JOIN_TABLE = createOrmDescriptor( JoinTable.class ); CollectionTable.class,
AnnotationDescriptor<Lob> LOB = createOrmDescriptor( Lob.class ); CollectionTableJpaAnnotation.class
AnnotationDescriptor<ManyToMany> MANY_TO_MANY = createOrmDescriptor( ManyToMany.class ); );
AnnotationDescriptor<ManyToOne> MANY_TO_ONE = createOrmDescriptor( ManyToOne.class ); OrmAnnotationDescriptor<Column,ColumnJpaAnnotation> COLUMN = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<MapKey> MAP_KEY = createOrmDescriptor( MapKey.class ); Column.class,
AnnotationDescriptor<MapKeyClass> MAP_KEY_CLASS = createOrmDescriptor( MapKeyClass.class ); ColumnJpaAnnotation.class
AnnotationDescriptor<MapKeyColumn> MAP_KEY_COLUMN = createOrmDescriptor( MapKeyColumn.class ); );
AnnotationDescriptor<MapKeyEnumerated> MAP_KEY_ENUMERATED = createOrmDescriptor( MapKeyEnumerated.class ); OrmAnnotationDescriptor<ColumnResult,ColumnResultJpaAnnotation> COLUMN_RESULT = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<MapKeyJoinColumns> MAP_KEY_JOIN_COLUMNS = createOrmDescriptor( MapKeyJoinColumns.class ); ColumnResult.class,
AnnotationDescriptor<MapKeyJoinColumn> MAP_KEY_JOIN_COLUMN = createOrmDescriptor( MapKeyJoinColumn.class, MAP_KEY_JOIN_COLUMNS ); ColumnResultJpaAnnotation.class
AnnotationDescriptor<MapKeyTemporal> MAP_KEY_TEMPORAL = createOrmDescriptor( MapKeyTemporal.class ); );
AnnotationDescriptor<MappedSuperclass> MAPPED_SUPERCLASS = createOrmDescriptor( MappedSuperclass.class ); OrmAnnotationDescriptor<ConstructorResult,ConstructorResultJpaAnnotation> CONSTRUCTOR_RESULT = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<MapsId> MAPS_ID = createOrmDescriptor( MapsId.class ); ConstructorResult.class,
AnnotationDescriptor<NamedAttributeNode> NAMED_ATTRIBUTE_NODE = createOrmDescriptor( NamedAttributeNode.class ); ConstructorResultJpaAnnotation.class
AnnotationDescriptor<NamedEntityGraphs> NAMED_ENTITY_GRAPHS = createOrmDescriptor( NamedEntityGraphs.class ); );
AnnotationDescriptor<NamedEntityGraph> NAMED_ENTITY_GRAPH = createOrmDescriptor( NamedEntityGraph.class, NAMED_ENTITY_GRAPHS ); OrmAnnotationDescriptor<Converts,ConvertsJpaAnnotation> CONVERTS = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<NamedNativeQueries> NAMED_NATIVE_QUERIES = createOrmDescriptor( NamedNativeQueries.class ); Converts.class,
AnnotationDescriptor<NamedNativeQuery> NAMED_NATIVE_QUERY = createOrmDescriptor( NamedNativeQuery.class, NAMED_NATIVE_QUERIES ); ConvertsJpaAnnotation.class
AnnotationDescriptor<NamedQueries> NAMED_QUERIES = createOrmDescriptor( NamedQueries.class ); );
AnnotationDescriptor<NamedQuery> NAMED_QUERY = createOrmDescriptor( NamedQuery.class, NAMED_QUERIES ); OrmAnnotationDescriptor<Convert,ConvertJpaAnnotation> CONVERT = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<NamedStoredProcedureQueries> NAMED_STORED_PROCEDURE_QUERIES = createOrmDescriptor( NamedStoredProcedureQueries.class ); Convert.class,
AnnotationDescriptor<NamedStoredProcedureQuery> NAMED_STORED_PROCEDURE_QUERY = createOrmDescriptor( NamedStoredProcedureQuery.class, NAMED_STORED_PROCEDURE_QUERIES ); ConvertJpaAnnotation.class,
AnnotationDescriptor<NamedSubgraph> NAMED_SUB_GRAPH = createOrmDescriptor( NamedSubgraph.class ); CONVERTS
AnnotationDescriptor<OneToMany> ONE_TO_MANY = createOrmDescriptor( OneToMany.class ); );
AnnotationDescriptor<OneToOne> ONE_TO_ONE = createOrmDescriptor( OneToOne.class ); OrmAnnotationDescriptor<Converter,ConverterJpaAnnotation> CONVERTER = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<OrderBy> ORDER_BY = createOrmDescriptor( OrderBy.class ); Converter.class,
AnnotationDescriptor<OrderColumn> ORDER_COLUMN = createOrmDescriptor( OrderColumn.class ); ConverterJpaAnnotation.class
AnnotationDescriptor<PostLoad> POST_LOAD = createOrmDescriptor( PostLoad.class ); );
AnnotationDescriptor<PostPersist> POST_PERSIST = createOrmDescriptor( PostPersist.class ); OrmAnnotationDescriptor<DiscriminatorColumn,DiscriminatorColumnJpaAnnotation> DISCRIMINATOR_COLUMN = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<PostRemove> POST_REMOVE = createOrmDescriptor( PostRemove.class ); DiscriminatorColumn.class,
AnnotationDescriptor<PostUpdate> POST_UPDATE = createOrmDescriptor( PostUpdate.class ); DiscriminatorColumnJpaAnnotation.class
AnnotationDescriptor<PrePersist> PRE_PERSIST = createOrmDescriptor( PrePersist.class ); );
AnnotationDescriptor<PreRemove> PRE_REMOVE = createOrmDescriptor( PreRemove.class ); OrmAnnotationDescriptor<DiscriminatorValue,DiscriminatorValueJpaAnnotation> DISCRIMINATOR_VALUE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<PreUpdate> PRE_UPDATE = createOrmDescriptor( PreUpdate.class ); DiscriminatorValue.class,
AnnotationDescriptor<PrimaryKeyJoinColumns> PRIMARY_KEY_JOIN_COLUMNS = createOrmDescriptor( PrimaryKeyJoinColumns.class ); DiscriminatorValueJpaAnnotation.class
AnnotationDescriptor<PrimaryKeyJoinColumn> PRIMARY_KEY_JOIN_COLUMN = createOrmDescriptor( PrimaryKeyJoinColumn.class, PRIMARY_KEY_JOIN_COLUMNS ); );
AnnotationDescriptor<QueryHint> QUERY_HINT = createOrmDescriptor( QueryHint.class ); OrmAnnotationDescriptor<ElementCollection,ElementCollectionJpaAnnotation> ELEMENT_COLLECTION = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<SecondaryTables> SECONDARY_TABLES = createOrmDescriptor( SecondaryTables.class ); ElementCollection.class,
AnnotationDescriptor<SecondaryTable> SECONDARY_TABLE = createOrmDescriptor( SecondaryTable.class, SECONDARY_TABLES ); ElementCollectionJpaAnnotation.class
AnnotationDescriptor<SequenceGenerators> SEQUENCE_GENERATORS = createOrmDescriptor( SequenceGenerators.class ); );
AnnotationDescriptor<SequenceGenerator> SEQUENCE_GENERATOR = createOrmDescriptor( SequenceGenerator.class, SEQUENCE_GENERATORS ); OrmAnnotationDescriptor<Embeddable,EmbeddableJpaAnnotation> EMBEDDABLE = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<SqlResultSetMappings> SQL_RESULT_SET_MAPPINGS = createOrmDescriptor( SqlResultSetMappings.class ); Embeddable.class,
AnnotationDescriptor<SqlResultSetMapping> SQL_RESULT_SET_MAPPING = createOrmDescriptor( SqlResultSetMapping.class, SQL_RESULT_SET_MAPPINGS ); EmbeddableJpaAnnotation.class
AnnotationDescriptor<StoredProcedureParameter> STORED_PROCEDURE_PARAMETER = createOrmDescriptor( StoredProcedureParameter.class ); );
AnnotationDescriptor<Table> TABLE = createOrmDescriptor( Table.class ); OrmAnnotationDescriptor<Embedded,EmbeddedJpaAnnotation> EMBEDDED = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<TableGenerators> TABLE_GENERATORS = createOrmDescriptor( TableGenerators.class ); Embedded.class,
AnnotationDescriptor<TableGenerator> TABLE_GENERATOR = createOrmDescriptor( TableGenerator.class, TABLE_GENERATORS ); EmbeddedJpaAnnotation.class
AnnotationDescriptor<Temporal> TEMPORAL = createOrmDescriptor( Temporal.class ); );
AnnotationDescriptor<Transient> TRANSIENT = createOrmDescriptor( Transient.class ); OrmAnnotationDescriptor<EmbeddedId,EmbeddedIdJpaAnnotation> EMBEDDED_ID = new OrmAnnotationDescriptor<>(
AnnotationDescriptor<UniqueConstraint> UNIQUE_CONSTRAINT = createOrmDescriptor( UniqueConstraint.class ); EmbeddedId.class,
AnnotationDescriptor<Version> VERSION = createOrmDescriptor( Version.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) { static void forEachAnnotation(Consumer<AnnotationDescriptor<? extends Annotation>> consumer) {
OrmAnnotationHelper.forEachOrmAnnotation( JpaAnnotations.class, 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