HHH-18072 - Transform hbm.xml not-found
This commit is contained in:
parent
6db0987a2c
commit
1cce4537ee
|
@ -27,6 +27,8 @@ import org.hibernate.annotations.JavaType;
|
||||||
import org.hibernate.annotations.JdbcType;
|
import org.hibernate.annotations.JdbcType;
|
||||||
import org.hibernate.annotations.JdbcTypeCode;
|
import org.hibernate.annotations.JdbcTypeCode;
|
||||||
import org.hibernate.annotations.NaturalIdCache;
|
import org.hibernate.annotations.NaturalIdCache;
|
||||||
|
import org.hibernate.annotations.NotFound;
|
||||||
|
import org.hibernate.annotations.NotFoundAction;
|
||||||
import org.hibernate.annotations.Parameter;
|
import org.hibernate.annotations.Parameter;
|
||||||
import org.hibernate.annotations.ResultCheckStyle;
|
import org.hibernate.annotations.ResultCheckStyle;
|
||||||
import org.hibernate.annotations.RowId;
|
import org.hibernate.annotations.RowId;
|
||||||
|
@ -61,8 +63,10 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumnImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbLifecycleCallback;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbLifecycleCallback;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbLifecycleCallbackContainer;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbLifecycleCallbackContainer;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbLobImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbLobImpl;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNationalizedImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbNationalizedImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNaturalId;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbNaturalId;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbNotFoundCapable;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSequenceGeneratorImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbSequenceGeneratorImpl;
|
||||||
|
@ -1478,4 +1482,22 @@ public class XmlAnnotationHelper {
|
||||||
.getDefaults()
|
.getDefaults()
|
||||||
.getCatalog();
|
.getCatalog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void applyNotFound(
|
||||||
|
JaxbNotFoundCapable jaxbNode,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
assert jaxbNode != null;
|
||||||
|
|
||||||
|
final NotFoundAction notFoundAction = jaxbNode.getNotFound();
|
||||||
|
if ( notFoundAction == null || jaxbNode.getNotFound() != NotFoundAction.EXCEPTION ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final MutableAnnotationUsage<NotFound> notFoundAnn = memberDetails.applyAnnotationUsage(
|
||||||
|
HibernateAnnotations.NOT_FOUND,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
notFoundAnn.setAttributeValue( "action", notFoundAction );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ public class ManyToManyAttributeProcessing {
|
||||||
|
|
||||||
XmlAnnotationHelper.applyJoinTableFilters( jaxbManyToMany.getJoinTableFilters(), memberDetails, xmlDocumentContext );
|
XmlAnnotationHelper.applyJoinTableFilters( jaxbManyToMany.getJoinTableFilters(), memberDetails, xmlDocumentContext );
|
||||||
|
|
||||||
|
XmlAnnotationHelper.applyNotFound( jaxbManyToMany, memberDetails, xmlDocumentContext );
|
||||||
|
|
||||||
return memberDetails;
|
return memberDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import jakarta.persistence.AccessType;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.MapsId;
|
import jakarta.persistence.MapsId;
|
||||||
|
|
||||||
|
import static org.hibernate.boot.models.xml.internal.XmlAnnotationHelper.applyNotFound;
|
||||||
import static org.hibernate.boot.models.xml.internal.XmlAnnotationHelper.determineTargetName;
|
import static org.hibernate.boot.models.xml.internal.XmlAnnotationHelper.determineTargetName;
|
||||||
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
import static org.hibernate.internal.util.NullnessHelper.coalesce;
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ public class ManyToOneAttributeProcessing {
|
||||||
TableProcessing.transformJoinTable( jaxbManyToOne.getJoinTable(), memberDetails, xmlDocumentContext );
|
TableProcessing.transformJoinTable( jaxbManyToOne.getJoinTable(), memberDetails, xmlDocumentContext );
|
||||||
JoinColumnProcessing.applyJoinColumns( jaxbManyToOne.getJoinColumns(), memberDetails, xmlDocumentContext );
|
JoinColumnProcessing.applyJoinColumns( jaxbManyToOne.getJoinColumns(), memberDetails, xmlDocumentContext );
|
||||||
|
|
||||||
applyNotFound( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
applyNotFound( jaxbManyToOne, memberDetails, xmlDocumentContext );
|
||||||
applyOnDelete( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
applyOnDelete( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||||
applyTarget( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
applyTarget( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||||
XmlAnnotationHelper.applyCascading( jaxbManyToOne.getCascade(), memberDetails, xmlDocumentContext );
|
XmlAnnotationHelper.applyCascading( jaxbManyToOne.getCascade(), memberDetails, xmlDocumentContext );
|
||||||
|
@ -93,23 +94,6 @@ public class ManyToOneAttributeProcessing {
|
||||||
return manyToOneUsage;
|
return manyToOneUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyNotFound(
|
|
||||||
MutableMemberDetails memberDetails,
|
|
||||||
JaxbManyToOneImpl jaxbManyToOne,
|
|
||||||
MutableAnnotationUsage<ManyToOne> manyToOneAnn,
|
|
||||||
XmlDocumentContext xmlDocumentContext) {
|
|
||||||
final NotFoundAction notFoundAction = jaxbManyToOne.getNotFound();
|
|
||||||
if ( notFoundAction == null ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final MutableAnnotationUsage<NotFound> notFoundAnn = memberDetails.applyAnnotationUsage(
|
|
||||||
HibernateAnnotations.NOT_FOUND,
|
|
||||||
xmlDocumentContext.getModelBuildingContext()
|
|
||||||
);
|
|
||||||
notFoundAnn.setAttributeValue( "action", notFoundAction );
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static void applyOnDelete(
|
private static void applyOnDelete(
|
||||||
MutableMemberDetails memberDetails,
|
MutableMemberDetails memberDetails,
|
||||||
|
|
|
@ -84,15 +84,7 @@ public class OneToManyAttributeProcessing {
|
||||||
onDeleteAnn.setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
onDeleteAnn.setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( jaxbOneToMany.getNotFound() != null ) {
|
XmlAnnotationHelper.applyNotFound( jaxbOneToMany, memberDetails, xmlDocumentContext );
|
||||||
if ( jaxbOneToMany.getNotFound() != NotFoundAction.EXCEPTION ) {
|
|
||||||
final MutableAnnotationUsage<NotFound> notFoundAnn = memberDetails.applyAnnotationUsage(
|
|
||||||
HibernateAnnotations.NOT_FOUND,
|
|
||||||
xmlDocumentContext.getModelBuildingContext()
|
|
||||||
);
|
|
||||||
notFoundAnn.setAttributeValue( "action", jaxbOneToMany.getNotFound() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return memberDetails;
|
return memberDetails;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue