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.JdbcTypeCode;
|
||||
import org.hibernate.annotations.NaturalIdCache;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Parameter;
|
||||
import org.hibernate.annotations.ResultCheckStyle;
|
||||
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.JaxbLifecycleCallbackContainer;
|
||||
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.JaxbNaturalId;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNotFoundCapable;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSequenceGeneratorImpl;
|
||||
|
@ -1478,4 +1482,22 @@ public class XmlAnnotationHelper {
|
|||
.getDefaults()
|
||||
.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.applyNotFound( jaxbManyToMany, memberDetails, xmlDocumentContext );
|
||||
|
||||
return memberDetails;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import jakarta.persistence.AccessType;
|
|||
import jakarta.persistence.ManyToOne;
|
||||
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.internal.util.NullnessHelper.coalesce;
|
||||
|
||||
|
@ -59,7 +60,7 @@ public class ManyToOneAttributeProcessing {
|
|||
TableProcessing.transformJoinTable( jaxbManyToOne.getJoinTable(), memberDetails, xmlDocumentContext );
|
||||
JoinColumnProcessing.applyJoinColumns( jaxbManyToOne.getJoinColumns(), memberDetails, xmlDocumentContext );
|
||||
|
||||
applyNotFound( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||
applyNotFound( jaxbManyToOne, memberDetails, xmlDocumentContext );
|
||||
applyOnDelete( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||
applyTarget( memberDetails, jaxbManyToOne, manyToOneAnn, xmlDocumentContext );
|
||||
XmlAnnotationHelper.applyCascading( jaxbManyToOne.getCascade(), memberDetails, xmlDocumentContext );
|
||||
|
@ -93,23 +94,6 @@ public class ManyToOneAttributeProcessing {
|
|||
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")
|
||||
private static void applyOnDelete(
|
||||
MutableMemberDetails memberDetails,
|
||||
|
|
|
@ -84,15 +84,7 @@ public class OneToManyAttributeProcessing {
|
|||
onDeleteAnn.setAttributeValue( "action", jaxbOneToMany.getOnDelete() );
|
||||
}
|
||||
|
||||
if ( jaxbOneToMany.getNotFound() != null ) {
|
||||
if ( jaxbOneToMany.getNotFound() != NotFoundAction.EXCEPTION ) {
|
||||
final MutableAnnotationUsage<NotFound> notFoundAnn = memberDetails.applyAnnotationUsage(
|
||||
HibernateAnnotations.NOT_FOUND,
|
||||
xmlDocumentContext.getModelBuildingContext()
|
||||
);
|
||||
notFoundAnn.setAttributeValue( "action", jaxbOneToMany.getNotFound() );
|
||||
}
|
||||
}
|
||||
XmlAnnotationHelper.applyNotFound( jaxbOneToMany, memberDetails, xmlDocumentContext );
|
||||
|
||||
return memberDetails;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue