Search in sources :

Example 1 with JaxbOneToOne

use of org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOne in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getOneToOne.

/**
 * As per section 12.2 of the JPA 2.0 specification, the association
 * subelements (many-to-one, one-to-many, one-to-one, many-to-many,
 * element-collection) completely override the mapping for the specified
 * field or property.  Thus, any methods which might in some contexts merge
 * with annotations must not do so in this context.
 *
 * @see #getElementCollection(List, XMLContext.Default)
 */
private void getOneToOne(List<Annotation> annotationList, XMLContext.Default defaults) {
    Class<OneToOne> annotationType = OneToOne.class;
    List<JaxbOneToOne> elements = elementsForProperty.getOneToOne();
    for (JaxbOneToOne element : elements) {
        AnnotationDescriptor ad = new AnnotationDescriptor(annotationType);
        addTargetClass(element.getTargetEntity(), ad, "target-entity", defaults);
        getFetchType(ad, element.getFetch());
        getCascades(ad, element.getCascade(), defaults);
        getJoinTable(annotationList, element, defaults);
        buildJoinColumns(annotationList, element.getJoinColumn());
        Annotation annotation = getPrimaryKeyJoinColumns(element.getPrimaryKeyJoinColumn(), defaults, false);
        addIfNotNull(annotationList, annotation);
        copyAttribute(ad, "optional", element.isOptional(), false);
        copyAttribute(ad, "orphan-removal", element.isOrphanRemoval(), false);
        copyAttribute(ad, "mapped-by", element.getMappedBy(), false);
        annotationList.add(AnnotationFactory.create(ad));
        getAssociationId(annotationList, element.isId());
        getMapsId(annotationList, element.getMapsId());
        getAccessType(annotationList, element.getAccess());
    }
    afterGetAssociation(annotationType, annotationList, defaults);
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) OneToOne(jakarta.persistence.OneToOne) JaxbOneToOne(org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOne) JaxbOneToOne(org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOne) Annotation(java.lang.annotation.Annotation)

Aggregations

OneToOne (jakarta.persistence.OneToOne)1 Annotation (java.lang.annotation.Annotation)1 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)1 JaxbOneToOne (org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOne)1