HHH-18000 : Remove XmlProcessingHelper methods for creating AnnotationUsage instances
This commit is contained in:
parent
b1ec34f660
commit
62178086a6
|
@ -1202,15 +1202,10 @@ public class XmlAnnotationHelper {
|
|||
JaxbEntityListenerImpl jaxbEntityListener,
|
||||
MutableClassDetails classDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<EntityListeners> applied = classDetails.applyAnnotationUsage(
|
||||
final MutableAnnotationUsage<EntityListeners> listenersUsage = classDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.ENTITY_LISTENERS,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
final MutableAnnotationUsage<EntityListeners> listenersUsage = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
EntityListeners.class,
|
||||
classDetails,
|
||||
xmlDocumentContext
|
||||
);
|
||||
|
||||
final MutableClassDetails entityListenerClass = xmlDocumentContext.resolveJavaType( jaxbEntityListener.getClazz() );
|
||||
applyLifecycleCallbacks(
|
||||
|
|
|
@ -15,8 +15,6 @@ import org.hibernate.boot.models.MemberResolutionException;
|
|||
import org.hibernate.boot.models.internal.AnnotationUsageHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.internal.dynamic.DynamicAnnotationUsage;
|
||||
import org.hibernate.models.spi.AnnotationTarget;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.FieldDetails;
|
||||
import org.hibernate.models.spi.MethodDetails;
|
||||
|
@ -111,70 +109,6 @@ public class XmlProcessingHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an existing annotation, or create one.
|
||||
* Used when applying XML in override mode.
|
||||
*/
|
||||
public static <A extends Annotation> MutableAnnotationUsage<A> getOrMakeAnnotation(
|
||||
Class<A> annotationType,
|
||||
MutableAnnotationTarget target,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final AnnotationUsage<A> existing = target.getAnnotationUsage( annotationType );
|
||||
if ( existing != null ) {
|
||||
return (MutableAnnotationUsage<A>) existing;
|
||||
}
|
||||
|
||||
return makeAnnotation( annotationType, target, xmlDocumentContext );
|
||||
}
|
||||
|
||||
public static <A extends Annotation> MutableAnnotationUsage<A> getOrMakeAnnotation(
|
||||
Class<A> annotationType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
|
||||
return makeAnnotation( annotationType, xmlDocumentContext );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a nested AnnotationUsage. The usage is created with the given target,
|
||||
* but it is not added to the target's annotations.
|
||||
*/
|
||||
public static <A extends Annotation> MutableAnnotationUsage<A> makeNestedAnnotation(
|
||||
Class<A> annotationType,
|
||||
AnnotationTarget target,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
return new DynamicAnnotationUsage<>(
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( annotationType ),
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
}
|
||||
|
||||
public static <A extends Annotation> MutableAnnotationUsage<A> makeNestedAnnotation(
|
||||
Class<A> annotationType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
return makeNestedAnnotation( annotationType, null, xmlDocumentContext );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an AnnotationUsage.
|
||||
* Used when applying XML in complete mode or when {@linkplain #getOrMakeAnnotation}
|
||||
* needs to make.
|
||||
*/
|
||||
public static <A extends Annotation> MutableAnnotationUsage<A> makeAnnotation(
|
||||
Class<A> annotationType,
|
||||
MutableAnnotationTarget target,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<A> created = makeNestedAnnotation( annotationType, target, xmlDocumentContext );
|
||||
target.addAnnotationUsage( created );
|
||||
return created;
|
||||
}
|
||||
|
||||
public static <A extends Annotation> MutableAnnotationUsage<A> makeAnnotation(
|
||||
Class<A> annotationType,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
return makeNestedAnnotation( annotationType, xmlDocumentContext );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an existing annotation by name, or create one.
|
||||
|
@ -199,7 +133,11 @@ public class XmlProcessingHelper {
|
|||
MutableAnnotationTarget target,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
if ( name == null ) {
|
||||
return makeAnnotation( annotationType, target, xmlDocumentContext );
|
||||
return xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( annotationType )
|
||||
.createUsage( null, xmlDocumentContext.getModelBuildingContext() );
|
||||
}
|
||||
|
||||
final AnnotationUsage<A> existing = target.getNamedAnnotationUsage( annotationType, name, attributeToMatch );
|
||||
|
@ -221,7 +159,11 @@ public class XmlProcessingHelper {
|
|||
String nameAttributeName,
|
||||
MutableAnnotationTarget target,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<A> created = makeNestedAnnotation( annotationType, target, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<A> created = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( annotationType )
|
||||
.createUsage( null, xmlDocumentContext.getModelBuildingContext() );
|
||||
target.addAnnotationUsage( created );
|
||||
created.setAttributeValue( nameAttributeName, name );
|
||||
return created;
|
||||
|
|
|
@ -19,6 +19,8 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingDiscriminatorImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingKeyImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbColumnImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.ColumnProcessing;
|
||||
|
@ -56,7 +58,10 @@ public class AnyMappingAttributeProcessing {
|
|||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<Any> anyAnn = XmlProcessingHelper.makeAnnotation( Any.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Any> anyAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ANY,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
|
||||
CommonAttributeProcessing.applyAttributeBasics( jaxbHbmAnyMapping, memberDetails, anyAnn, accessType, xmlDocumentContext );
|
||||
|
||||
|
@ -73,7 +78,10 @@ public class AnyMappingAttributeProcessing {
|
|||
MutableAnnotationUsage<Any> anyAnn,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final JaxbAnyMappingDiscriminatorImpl jaxbDiscriminator = jaxbHbmAnyMapping.getDiscriminator();
|
||||
final MutableAnnotationUsage<AnyDiscriminator> anyDiscriminatorAnn = XmlProcessingHelper.makeAnnotation( AnyDiscriminator.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<AnyDiscriminator> anyDiscriminatorAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ANY_DISCRIMINATOR,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
|
||||
if ( jaxbDiscriminator == null ) {
|
||||
return;
|
||||
|
@ -83,29 +91,39 @@ public class AnyMappingAttributeProcessing {
|
|||
XmlProcessingHelper.applyAttributeIfSpecified( "value", discriminatorType, anyDiscriminatorAnn );
|
||||
|
||||
final JaxbColumnImpl jaxbColumn = jaxbDiscriminator.getColumn();
|
||||
final MutableAnnotationUsage<Column> columnAnn = XmlProcessingHelper.makeAnnotation( Column.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Column> columnAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.COLUMN,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
if ( jaxbColumn != null ) {
|
||||
ColumnProcessing.applyColumnDetails( jaxbColumn, memberDetails, columnAnn, xmlDocumentContext );
|
||||
}
|
||||
|
||||
final ClassDetailsRegistry classDetailsRegistry = xmlDocumentContext.getModelBuildingContext().getClassDetailsRegistry();
|
||||
final List<JaxbAnyDiscriminatorValueMappingImpl> valueMappings = jaxbDiscriminator.getValueMappings();
|
||||
if ( CollectionHelper.isNotEmpty( valueMappings ) ) {
|
||||
final MutableAnnotationUsage<AnyDiscriminatorValues> valuesAnn = XmlProcessingHelper.makeAnnotation( AnyDiscriminatorValues.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<AnyDiscriminatorValues> discriminatorValuesUsage = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ANY_DISCRIMINATOR_VALUES,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
final List<MutableAnnotationUsage<AnyDiscriminatorValue>> valueList = CollectionHelper.arrayList( valueMappings.size() );
|
||||
final ClassDetailsRegistry classDetailsRegistry = xmlDocumentContext.getModelBuildingContext().getClassDetailsRegistry();
|
||||
valuesAnn.setAttributeValue( "value", valueList );
|
||||
valueMappings.forEach( (valueMapping) -> {
|
||||
final MutableAnnotationUsage<AnyDiscriminatorValue> valueAnn = XmlProcessingHelper.makeNestedAnnotation( AnyDiscriminatorValue.class, memberDetails, xmlDocumentContext );
|
||||
valueList.add( valueAnn );
|
||||
discriminatorValuesUsage.setAttributeValue( "value", valueList );
|
||||
|
||||
valueAnn.setAttributeValue( "discriminator", valueMapping.getDiscriminatorValue() );
|
||||
valueMappings.forEach( (valueMapping) -> {
|
||||
final MutableAnnotationUsage<AnyDiscriminatorValue> discriminatorValueUsage = HibernateAnnotations.ANY_DISCRIMINATOR_VALUE.createUsage(
|
||||
null,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
valueList.add( discriminatorValueUsage );
|
||||
|
||||
discriminatorValueUsage.setAttributeValue( "discriminator", valueMapping.getDiscriminatorValue() );
|
||||
|
||||
final String name = StringHelper.qualifyConditionally(
|
||||
xmlDocumentContext.getXmlDocument().getDefaults().getPackage(),
|
||||
valueMapping.getCorrespondingEntityName()
|
||||
);
|
||||
final ClassDetails entityClassDetails = classDetailsRegistry.resolveClassDetails( name );
|
||||
valueAnn.setAttributeValue( "entity", entityClassDetails );
|
||||
discriminatorValueUsage.setAttributeValue( "entity", entityClassDetails );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -117,22 +135,31 @@ public class AnyMappingAttributeProcessing {
|
|||
XmlDocumentContext xmlDocumentContext) {
|
||||
final JaxbAnyMappingKeyImpl jaxbKey = jaxbHbmAnyMapping.getKey();
|
||||
if ( StringHelper.isNotEmpty( jaxbKey.getType() ) ) {
|
||||
final MutableAnnotationUsage<AnyKeyType> keyTypeAnn = XmlProcessingHelper.makeAnnotation( AnyKeyType.class, memberDetails, xmlDocumentContext );
|
||||
keyTypeAnn.setAttributeValue( "value", jaxbKey.getType() );
|
||||
final MutableAnnotationUsage<AnyKeyType> keyTypeUsage = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ANY_KEY_TYPE,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
keyTypeUsage.setAttributeValue( "value", jaxbKey.getType() );
|
||||
}
|
||||
|
||||
if ( jaxbKey.getColumns().isEmpty() ) {
|
||||
XmlProcessingHelper.makeAnnotation( JoinColumn.class, memberDetails, xmlDocumentContext );
|
||||
memberDetails.applyAnnotationUsage( JpaAnnotations.JOIN_COLUMN, xmlDocumentContext.getModelBuildingContext() );
|
||||
}
|
||||
else {
|
||||
final MutableAnnotationUsage<JoinColumns> columnsAnn = XmlProcessingHelper.makeAnnotation( JoinColumns.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<JoinColumns> joinColumnsUsage = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.JOIN_COLUMNS,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
final ArrayList<MutableAnnotationUsage<JoinColumn>> columnAnnList = CollectionHelper.arrayList( jaxbKey.getColumns().size() );
|
||||
columnsAnn.setAttributeValue( "value", columnAnnList );
|
||||
joinColumnsUsage.setAttributeValue( "value", columnAnnList );
|
||||
jaxbKey.getColumns().forEach( (jaxbColumn) -> {
|
||||
final MutableAnnotationUsage<JoinColumn> columnAnn = XmlProcessingHelper.makeNestedAnnotation( JoinColumn.class, memberDetails, xmlDocumentContext );
|
||||
columnAnnList.add( columnAnn );
|
||||
final MutableAnnotationUsage<JoinColumn> joinColumnUsage = JpaAnnotations.JOIN_COLUMN.createUsage(
|
||||
null,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
columnAnnList.add( joinColumnUsage );
|
||||
|
||||
ColumnProcessing.applyColumnDetails( jaxbColumn, memberDetails, columnAnn, xmlDocumentContext );
|
||||
ColumnProcessing.applyColumnDetails( jaxbColumn, memberDetails, joinColumnUsage, xmlDocumentContext );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.boot.models.xml.internal.attr;
|
|||
|
||||
import org.hibernate.annotations.Formula;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbBasicImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.ColumnProcessing;
|
||||
|
@ -40,16 +42,25 @@ public class BasicAttributeProcessing {
|
|||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<Basic> basicAnn = XmlProcessingHelper.getOrMakeAnnotation( Basic.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Basic> basicAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.BASIC,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
CommonAttributeProcessing.applyAttributeBasics( jaxbBasic, memberDetails, basicAnn, accessType, xmlDocumentContext );
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbBasic.getFormula() ) ) {
|
||||
assert jaxbBasic.getColumn() == null;
|
||||
final MutableAnnotationUsage<Formula> formulaAnn = XmlProcessingHelper.getOrMakeAnnotation( Formula.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Formula> formulaAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.FORMULA,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
formulaAnn.setAttributeValue( "value", jaxbBasic.getFormula() );
|
||||
}
|
||||
else if ( jaxbBasic.getColumn() != null ) {
|
||||
final MutableAnnotationUsage<Column> columnAnn = XmlProcessingHelper.getOrMakeAnnotation( Column.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Column> columnAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.COLUMN,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
ColumnProcessing.applyColumnDetails( jaxbBasic.getColumn(), memberDetails, columnAnn, xmlDocumentContext );
|
||||
}
|
||||
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdImpl;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableClassDetails;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
|
@ -37,8 +37,8 @@ public class BasicIdAttributeProcessing {
|
|||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<Id> idAnn = XmlProcessingHelper.makeAnnotation( Id.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Basic> basicAnn = XmlProcessingHelper.makeAnnotation( Basic.class, memberDetails, xmlDocumentContext );
|
||||
memberDetails.applyAnnotationUsage( JpaAnnotations.ID, xmlDocumentContext.getModelBuildingContext() );
|
||||
final MutableAnnotationUsage<Basic> basicAnn = memberDetails.applyAnnotationUsage( JpaAnnotations.BASIC, xmlDocumentContext.getModelBuildingContext() );
|
||||
|
||||
CommonAttributeProcessing.applyAttributeBasics( jaxbId, memberDetails, basicAnn, accessType, xmlDocumentContext );
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbSingularAssociationAttribute;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSingularFetchModeImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbStandardAttribute;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTransientImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.spi.ClassDetails;
|
||||
|
@ -29,9 +32,6 @@ import org.hibernate.models.spi.MutableMemberDetails;
|
|||
import jakarta.persistence.Access;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Transient;
|
||||
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -61,7 +61,10 @@ public class CommonAttributeProcessing {
|
|||
AccessType accessType,
|
||||
MutableMemberDetails memberDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<Access> accessAnn = XmlProcessingHelper.makeAnnotation( Access.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Access> accessAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.ACCESS,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
accessAnn.setAttributeValue( "value", accessType );
|
||||
}
|
||||
|
||||
|
@ -74,12 +77,16 @@ public class CommonAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<AttributeAccessor> accessorAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ATTRIBUTE_ACCESSOR,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
|
||||
final ClassDetails strategyClassDetails = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getClassDetailsRegistry()
|
||||
.getClassDetails( attributeAccessor );
|
||||
final MutableAnnotationUsage<AttributeAccessor> accessAnn = XmlProcessingHelper.makeAnnotation( AttributeAccessor.class, memberDetails, xmlDocumentContext );
|
||||
XmlProcessingHelper.applyAttributeIfSpecified( "strategy", strategyClassDetails, accessAnn );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( accessorAnn, "strategy", strategyClassDetails );
|
||||
}
|
||||
|
||||
public static <A extends Annotation> void applyOptionality(
|
||||
|
@ -100,7 +107,10 @@ public class CommonAttributeProcessing {
|
|||
MutableMemberDetails memberDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final boolean includeInOptimisticLock = jaxbAttribute.isOptimisticLock();
|
||||
final MutableAnnotationUsage<OptimisticLock> optLockAnn = XmlProcessingHelper.makeAnnotation( OptimisticLock.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<OptimisticLock> optLockAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.OPTIMISTIC_LOCK,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
optLockAnn.setAttributeValue( "excluded", !includeInOptimisticLock );
|
||||
}
|
||||
|
||||
|
@ -128,7 +138,10 @@ public class CommonAttributeProcessing {
|
|||
XmlDocumentContext xmlDocumentContext) {
|
||||
if ( jaxbFetchMode != null ) {
|
||||
final FetchMode fetchMode = FetchMode.valueOf( jaxbFetchMode.value() );
|
||||
final MutableAnnotationUsage<Fetch> fetchAnn = XmlProcessingHelper.makeAnnotation( Fetch.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Fetch> fetchAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.FETCH,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
fetchAnn.setAttributeValue( "value", fetchMode );
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +156,6 @@ public class CommonAttributeProcessing {
|
|||
classAccessType,
|
||||
declarer
|
||||
);
|
||||
XmlProcessingHelper.makeAnnotation( Transient.class, memberDetails, xmlDocumentContext );
|
||||
memberDetails.applyAnnotationUsage( JpaAnnotations.TRANSIENT, xmlDocumentContext.getModelBuildingContext() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.annotations.Bag;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.SortComparator;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
|
@ -16,6 +15,7 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumnImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.ColumnProcessing;
|
||||
|
@ -51,19 +51,23 @@ public class CommonPluralAttributeProcessing {
|
|||
final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
|
||||
|
||||
if ( jaxbPluralAttribute.getFetchMode() != null ) {
|
||||
final MutableAnnotationUsage<Fetch> fetchAnn = XmlProcessingHelper.getOrMakeAnnotation( Fetch.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Fetch> fetchAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.FETCH,
|
||||
buildingContext
|
||||
);
|
||||
fetchAnn.setAttributeValue( "value", jaxbPluralAttribute.getFetchMode() );
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getClassification() != null ) {
|
||||
final MutableAnnotationUsage<CollectionClassification> collectionClassificationAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
CollectionClassification.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
if ( jaxbPluralAttribute.getClassification() == LimitedCollectionClassification.BAG ) {
|
||||
memberDetails.applyAnnotationUsage( HibernateAnnotations.BAG, buildingContext );
|
||||
}
|
||||
else {
|
||||
final MutableAnnotationUsage<CollectionClassification> collectionClassificationAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.COLLECTION_CLASSIFICATION,
|
||||
buildingContext
|
||||
);
|
||||
collectionClassificationAnn.setAttributeValue( "value", jaxbPluralAttribute.getClassification() );
|
||||
if ( jaxbPluralAttribute.getClassification() == LimitedCollectionClassification.BAG ) {
|
||||
XmlProcessingHelper.getOrMakeAnnotation( Bag.class, memberDetails, xmlDocumentContext );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,10 +79,9 @@ public class CommonPluralAttributeProcessing {
|
|||
XmlAnnotationHelper.applyCollectionId( jaxbPluralAttribute.getCollectionId(), memberDetails, xmlDocumentContext );
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbPluralAttribute.getOrderBy() ) ) {
|
||||
final MutableAnnotationUsage<OrderBy> orderByAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
OrderBy.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
final MutableAnnotationUsage<OrderBy> orderByAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.ORDER_BY,
|
||||
buildingContext
|
||||
);
|
||||
orderByAnn.setAttributeValue( "value", jaxbPluralAttribute.getOrderBy() );
|
||||
}
|
||||
|
@ -86,51 +89,55 @@ public class CommonPluralAttributeProcessing {
|
|||
applyOrderColumn( jaxbPluralAttribute, memberDetails, xmlDocumentContext );
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbPluralAttribute.getSort() ) ) {
|
||||
final MutableAnnotationUsage<SortComparator> sortAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
SortComparator.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
final MutableAnnotationUsage<SortComparator> sortAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.SORT_COMPARATOR,
|
||||
buildingContext
|
||||
);
|
||||
final ClassDetails comparatorClassDetails = classDetailsRegistry.resolveClassDetails( jaxbPluralAttribute.getSort() );
|
||||
sortAnn.setAttributeValue( "value", comparatorClassDetails );
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getSortNatural() != null ) {
|
||||
XmlProcessingHelper.getOrMakeAnnotation( SortNatural.class, memberDetails, xmlDocumentContext );
|
||||
memberDetails.applyAnnotationUsage( HibernateAnnotations.SORT_NATURAL, buildingContext );
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// map-key
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKey() != null ) {
|
||||
final MutableAnnotationUsage<MapKey> mapKeyAnn = XmlProcessingHelper.getOrMakeAnnotation( MapKey.class, memberDetails, xmlDocumentContext );
|
||||
applyOr(
|
||||
jaxbPluralAttribute.getMapKey(),
|
||||
JaxbMapKeyImpl::getName,
|
||||
"name",
|
||||
mapKeyAnn,
|
||||
buildingContext.getAnnotationDescriptorRegistry().getDescriptor( MapKey.class )
|
||||
final MutableAnnotationUsage<MapKey> mapKeyAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MAP_KEY,
|
||||
buildingContext
|
||||
);
|
||||
if ( jaxbPluralAttribute.getMapKey() != null ) {
|
||||
XmlAnnotationHelper.applyOptionalAttribute( mapKeyAnn, "name", jaxbPluralAttribute.getMapKey().getName() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKeyClass() != null ) {
|
||||
final String className = xmlDocumentContext.resolveClassName( jaxbPluralAttribute.getMapKeyClass().getClazz() );
|
||||
final ClassDetails mapKeyClass = classDetailsRegistry.resolveClassDetails( className );
|
||||
XmlProcessingHelper.getOrMakeAnnotation( MapKeyClass.class, memberDetails, xmlDocumentContext ).setAttributeValue( "value", mapKeyClass );
|
||||
final MutableAnnotationUsage<MapKeyClass> mapKeyClassAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MAP_KEY_CLASS,
|
||||
buildingContext
|
||||
);
|
||||
mapKeyClassAnn.setAttributeValue( "value", mapKeyClass );
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKeyTemporal() != null ) {
|
||||
XmlProcessingHelper.getOrMakeAnnotation( MapKeyTemporal.class, memberDetails, xmlDocumentContext ).setAttributeValue(
|
||||
"value",
|
||||
jaxbPluralAttribute.getMapKeyTemporal()
|
||||
final MutableAnnotationUsage<MapKeyTemporal> mapKeyTemporalAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MAP_KEY_TEMPORAL,
|
||||
buildingContext
|
||||
);
|
||||
mapKeyTemporalAnn.setAttributeValue( "value", jaxbPluralAttribute.getMapKeyTemporal() );
|
||||
}
|
||||
|
||||
if ( jaxbPluralAttribute.getMapKeyEnumerated() != null ) {
|
||||
XmlProcessingHelper.getOrMakeAnnotation( MapKeyEnumerated.class, memberDetails, xmlDocumentContext ).setAttributeValue(
|
||||
"value",
|
||||
jaxbPluralAttribute.getMapKeyEnumerated()
|
||||
final MutableAnnotationUsage<MapKeyEnumerated> mapKeyEnumeratedAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MAP_KEY_ENUMERATED,
|
||||
buildingContext
|
||||
);
|
||||
mapKeyEnumeratedAnn.setAttributeValue( "value", jaxbPluralAttribute.getMapKeyEnumerated() );
|
||||
}
|
||||
|
||||
jaxbPluralAttribute.getMapKeyConverts().forEach( (jaxbConvert) -> {
|
||||
|
@ -167,20 +174,16 @@ public class CommonPluralAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<OrderColumn> orderColumnAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
OrderColumn.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
final MutableAnnotationUsage<OrderColumn> orderColumnAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.ORDER_COLUMN,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
final AnnotationDescriptor<OrderColumn> orderColumnDescriptor = xmlDocumentContext.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( OrderColumn.class );
|
||||
|
||||
applyOr( jaxbOrderColumn, JaxbOrderColumnImpl::getName, "name", orderColumnAnn, orderColumnDescriptor );
|
||||
applyOr( jaxbOrderColumn, JaxbOrderColumnImpl::isNullable, "nullable", orderColumnAnn, orderColumnDescriptor );
|
||||
applyOr( jaxbOrderColumn, JaxbOrderColumnImpl::isInsertable, "insertable", orderColumnAnn, orderColumnDescriptor );
|
||||
applyOr( jaxbOrderColumn, JaxbOrderColumnImpl::isUpdatable, "updatable", orderColumnAnn, orderColumnDescriptor );
|
||||
applyOr( jaxbOrderColumn, JaxbOrderColumnImpl::getColumnDefinition, "columnDefinition", orderColumnAnn, orderColumnDescriptor );
|
||||
applyOr( jaxbOrderColumn, JaxbOrderColumnImpl::getOptions, "options", orderColumnAnn, orderColumnDescriptor );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( orderColumnAnn, "name", jaxbOrderColumn.getName() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( orderColumnAnn, "nullable", jaxbOrderColumn.isNullable() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( orderColumnAnn, "insertable", jaxbOrderColumn.isInsertable() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( orderColumnAnn, "updatable", jaxbOrderColumn.isUpdatable() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( orderColumnAnn, "columnDefinition", jaxbOrderColumn.getColumnDefinition() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( orderColumnAnn, "options", jaxbOrderColumn.getOptions() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,10 +101,9 @@ public class ElementCollectionAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<CollectionTable> collectionTableAnn = XmlProcessingHelper.getOrMakeAnnotation(
|
||||
CollectionTable.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
final MutableAnnotationUsage<CollectionTable> collectionTableAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.COLLECTION_TABLE,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
final AnnotationDescriptor<CollectionTable> collectionTableDescriptor = xmlDocumentContext.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.boot.models.xml.internal.attr;
|
|||
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
|
@ -39,10 +41,16 @@ public class EmbeddedAttributeProcessing {
|
|||
declarer
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<Embedded> embeddedAnn = XmlProcessingHelper.getOrMakeAnnotation( Embedded.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Embedded> embeddedAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.EMBEDDED,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbEmbedded.getTarget() ) ) {
|
||||
final MutableAnnotationUsage<Target> targetAnn = XmlProcessingHelper.getOrMakeAnnotation( Target.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Target> targetAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.TARGET,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
targetAnn.setAttributeValue( "value", determineTargetName( jaxbEmbedded.getTarget(), xmlDocumentContext ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,15 @@ package org.hibernate.boot.models.xml.internal.attr;
|
|||
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedIdImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableClassDetails;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
|
@ -39,11 +41,17 @@ public class EmbeddedIdAttributeProcessing {
|
|||
classDetails
|
||||
);
|
||||
|
||||
final MutableAnnotationUsage<EmbeddedId> idAnn = XmlProcessingHelper.makeAnnotation( EmbeddedId.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<EmbeddedId> idAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.EMBEDDED_ID,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
CommonAttributeProcessing.applyAttributeBasics( jaxbEmbeddedId, memberDetails, idAnn, accessType, xmlDocumentContext );
|
||||
|
||||
if ( StringHelper.isNotEmpty( jaxbEmbeddedId.getTarget() ) ) {
|
||||
final MutableAnnotationUsage<Target> targetAnn = XmlProcessingHelper.getOrMakeAnnotation( Target.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Target> targetAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.TARGET,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
targetAnn.setAttributeValue( "value", determineTargetName( jaxbEmbeddedId.getTarget(), xmlDocumentContext ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -7,20 +7,19 @@
|
|||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.TableProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableClassDetails;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
import org.hibernate.models.spi.AnnotationDescriptor;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
import static org.hibernate.boot.models.xml.internal.XmlProcessingHelper.getOrMakeAnnotation;
|
||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
/**
|
||||
|
@ -74,18 +73,15 @@ public class ManyToManyAttributeProcessing {
|
|||
JaxbManyToManyImpl jaxbManyToMany,
|
||||
MutableMemberDetails memberDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<ManyToMany> manyToManyAnn = getOrMakeAnnotation(
|
||||
ManyToMany.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
final MutableAnnotationUsage<ManyToMany> manyToManyAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MANY_TO_MANY,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
final AnnotationDescriptor<ManyToMany> manyToManyDescriptor = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( ManyToMany.class );
|
||||
|
||||
XmlAnnotationHelper.applyOr( jaxbManyToMany, JaxbManyToManyImpl::getFetch, "fetch", manyToManyAnn, manyToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbManyToMany, JaxbManyToManyImpl::getMappedBy, "mappedBy", manyToManyAnn, manyToManyDescriptor );
|
||||
if ( jaxbManyToMany != null ) {
|
||||
XmlAnnotationHelper.applyOptionalAttribute( manyToManyAnn, "fetch", jaxbManyToMany.getFetch() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( manyToManyAnn, "mappedBy", jaxbManyToMany.getMappedBy() );
|
||||
}
|
||||
|
||||
return manyToManyAnn;
|
||||
}
|
||||
|
|
|
@ -6,15 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.boot.models.xml.internal.attr;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.hibernate.boot.internal.Target;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOneImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
|
@ -22,7 +20,6 @@ import org.hibernate.boot.models.xml.internal.db.JoinColumnProcessing;
|
|||
import org.hibernate.boot.models.xml.internal.db.TableProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableClassDetails;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
|
@ -74,13 +71,13 @@ public class ManyToOneAttributeProcessing {
|
|||
MutableMemberDetails memberDetails,
|
||||
JaxbManyToOneImpl jaxbManyToOne,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<ManyToOne> manyToOneUsage = XmlProcessingHelper.getOrMakeAnnotation( ManyToOne.class, memberDetails, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyOptionalAttribute(
|
||||
manyToOneUsage,
|
||||
"fetch",
|
||||
jaxbManyToOne.getFetch()
|
||||
final MutableAnnotationUsage<ManyToOne> manyToOneUsage = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MANY_TO_ONE,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
|
||||
XmlAnnotationHelper.applyOptionalAttribute( manyToOneUsage, "fetch", jaxbManyToOne.getFetch() );
|
||||
|
||||
if ( jaxbManyToOne.isId() == Boolean.TRUE ) {
|
||||
memberDetails.applyAnnotationUsage( JpaAnnotations.ID, xmlDocumentContext.getModelBuildingContext() );
|
||||
}
|
||||
|
@ -106,7 +103,10 @@ public class ManyToOneAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<NotFound> notFoundAnn = XmlProcessingHelper.makeAnnotation( NotFound.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<NotFound> notFoundAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.NOT_FOUND,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
notFoundAnn.setAttributeValue( "action", notFoundAction );
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,10 @@ public class ManyToOneAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<OnDelete> notFoundAnn = XmlProcessingHelper.makeAnnotation( OnDelete.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<OnDelete> notFoundAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ON_DELETE,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
notFoundAnn.setAttributeValue( "action", action );
|
||||
}
|
||||
|
||||
|
@ -136,13 +139,10 @@ public class ManyToOneAttributeProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<Target> targetAnn = XmlProcessingHelper.makeAnnotation( Target.class, memberDetails, xmlDocumentContext );
|
||||
final MutableAnnotationUsage<Target> targetAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.TARGET,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
targetAnn.setAttributeValue( "value", determineTargetName( targetEntityName, xmlDocumentContext ) );
|
||||
}
|
||||
|
||||
private static <E extends Enum<E>> List<E> asList(EnumSet<E> enums) {
|
||||
final List<E> list = CollectionHelper.arrayList( enums.size() );
|
||||
list.addAll( enums );
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,13 @@ import org.hibernate.annotations.NotFound;
|
|||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToManyImpl;
|
||||
import org.hibernate.boot.models.HibernateAnnotations;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.internal.db.TableProcessing;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.models.spi.AnnotationDescriptor;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableClassDetails;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
|
@ -77,12 +78,20 @@ public class OneToManyAttributeProcessing {
|
|||
} );
|
||||
|
||||
if ( jaxbOneToMany.getOnDelete() != null ) {
|
||||
XmlProcessingHelper.getOrMakeAnnotation( OnDelete.class, memberDetails, xmlDocumentContext ).setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
||||
final MutableAnnotationUsage<OnDelete> onDeleteAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.ON_DELETE,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
onDeleteAnn.setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
||||
}
|
||||
|
||||
if ( jaxbOneToMany.getNotFound() != null ) {
|
||||
if ( jaxbOneToMany.getNotFound() != NotFoundAction.EXCEPTION ) {
|
||||
XmlProcessingHelper.getOrMakeAnnotation( NotFound.class, memberDetails, xmlDocumentContext ).setAttributeValue( "action", jaxbOneToMany.getNotFound() );
|
||||
final MutableAnnotationUsage<NotFound> notFoundAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.NOT_FOUND,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
notFoundAnn.setAttributeValue( "action", jaxbOneToMany.getNotFound() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,15 +102,16 @@ public class OneToManyAttributeProcessing {
|
|||
JaxbOneToManyImpl jaxbOneToMany,
|
||||
MutableMemberDetails memberDetails,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
final MutableAnnotationUsage<OneToMany> oneToManyAnn = XmlProcessingHelper.getOrMakeAnnotation( OneToMany.class, memberDetails, xmlDocumentContext );
|
||||
final AnnotationDescriptor<OneToMany> oneToManyDescriptor = xmlDocumentContext
|
||||
.getModelBuildingContext()
|
||||
.getAnnotationDescriptorRegistry()
|
||||
.getDescriptor( OneToMany.class );
|
||||
final MutableAnnotationUsage<OneToMany> oneToManyAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.ONE_TO_MANY,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
|
||||
XmlAnnotationHelper.applyOr( jaxbOneToMany, JaxbOneToManyImpl::getFetch, "fetch", oneToManyAnn, oneToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbOneToMany, JaxbOneToManyImpl::getMappedBy, "mappedBy", oneToManyAnn, oneToManyDescriptor );
|
||||
XmlAnnotationHelper.applyOr( jaxbOneToMany, JaxbOneToManyImpl::isOrphanRemoval, "orphanRemoval", oneToManyAnn, oneToManyDescriptor );
|
||||
if ( jaxbOneToMany != null ) {
|
||||
XmlAnnotationHelper.applyOptionalAttribute( oneToManyAnn, "fetch", jaxbOneToMany.getFetch() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( oneToManyAnn, "mappedBy", jaxbOneToMany.getMappedBy() );
|
||||
XmlAnnotationHelper.applyOptionalAttribute( oneToManyAnn, "orphanRemoval", jaxbOneToMany.isOrphanRemoval() );
|
||||
}
|
||||
|
||||
return oneToManyAnn;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnSizable;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnStandard;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbColumnUniqueable;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.db.JaxbCommentable;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.internal.AnnotationUsageHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.models.spi.AnnotationTarget;
|
||||
import org.hibernate.models.spi.MutableAnnotationTarget;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
|
||||
|
@ -210,8 +210,10 @@ public class ColumnProcessing {
|
|||
return;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<MapKeyColumn> columnAnn = XmlProcessingHelper.getOrMakeAnnotation( MapKeyColumn.class, memberDetails, xmlDocumentContext );
|
||||
|
||||
final MutableAnnotationUsage<MapKeyColumn> columnAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.MAP_KEY_COLUMN,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
applyColumnDetails( jaxbMapKeyColumn, memberDetails, columnAnn, xmlDocumentContext );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
|||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.AnnotationTarget;
|
||||
import org.hibernate.models.spi.AnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableAnnotationTarget;
|
||||
import org.hibernate.models.spi.MutableAnnotationUsage;
|
||||
import org.hibernate.models.spi.MutableMemberDetails;
|
||||
|
||||
|
@ -213,10 +212,9 @@ public class JoinColumnProcessing {
|
|||
XmlAnnotationHelper.applyJoinColumn( jaxbJoinColumns.get( 0 ), memberDetails, xmlDocumentContext );
|
||||
}
|
||||
else {
|
||||
final MutableAnnotationUsage<JoinColumns> columnsAnn = XmlProcessingHelper.makeAnnotation(
|
||||
JoinColumns.class,
|
||||
memberDetails,
|
||||
xmlDocumentContext
|
||||
final MutableAnnotationUsage<JoinColumns> columnsAnn = memberDetails.applyAnnotationUsage(
|
||||
JpaAnnotations.JOIN_COLUMNS,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
columnsAnn.setAttributeValue( "value", createJoinColumns( jaxbJoinColumns, memberDetails, xmlDocumentContext ) );
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumnImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinTableImpl;
|
||||
import org.hibernate.boot.models.JpaAnnotations;
|
||||
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
|
||||
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
|
||||
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.models.spi.AnnotationTarget;
|
||||
|
@ -41,23 +40,6 @@ public class TableProcessing {
|
|||
return joinTableUsage;
|
||||
}
|
||||
|
||||
public static MutableAnnotationUsage<JoinTable> createNestedJoinTable(
|
||||
JaxbJoinTableImpl jaxbJoinTable,
|
||||
AnnotationTarget annotationTarget,
|
||||
XmlDocumentContext xmlDocumentContext) {
|
||||
if ( jaxbJoinTable == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final MutableAnnotationUsage<JoinTable> joinTableAnn = XmlProcessingHelper.makeNestedAnnotation(
|
||||
JoinTable.class,
|
||||
annotationTarget,
|
||||
xmlDocumentContext
|
||||
);
|
||||
applyJoinTable( jaxbJoinTable, joinTableAnn, annotationTarget, xmlDocumentContext );
|
||||
return joinTableAnn;
|
||||
}
|
||||
|
||||
private static void applyJoinTable(
|
||||
JaxbJoinTableImpl jaxbJoinTable,
|
||||
MutableAnnotationUsage<JoinTable> joinTableUsage,
|
||||
|
|
Loading…
Reference in New Issue