Search in sources :

Example 6 with AssociationOverride

use of jakarta.persistence.AssociationOverride in project hibernate-orm by hibernate.

the class Ejb3XmlElementCollectionTest method testSingleAssociationOverride.

/**
 * When there's a single association override, we still wrap it with an
 * AssociationOverrides annotation.
 */
@Test
public void testSingleAssociationOverride() throws Exception {
    reader = getReader(Entity3.class, "field1", "element-collection.orm24.xml");
    assertAnnotationPresent(ElementCollection.class);
    assertAnnotationNotPresent(AssociationOverride.class);
    assertAnnotationPresent(AssociationOverrides.class);
    AssociationOverrides overridesAnno = reader.getAnnotation(AssociationOverrides.class);
    AssociationOverride[] overrides = overridesAnno.value();
    assertEquals(1, overrides.length);
    assertEquals("association1", overrides[0].name());
    assertEquals(0, overrides[0].joinColumns().length);
    assertEquals("", overrides[0].joinTable().name());
}
Also used : AssociationOverrides(jakarta.persistence.AssociationOverrides) AssociationOverride(jakarta.persistence.AssociationOverride) Test(org.junit.Test)

Aggregations

AssociationOverride (jakarta.persistence.AssociationOverride)6 AssociationOverrides (jakarta.persistence.AssociationOverrides)4 JaxbAssociationOverride (org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationOverride)3 JoinTable (jakarta.persistence.JoinTable)2 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)2 Test (org.junit.Test)2 JoinColumn (jakarta.persistence.JoinColumn)1 MapKeyJoinColumn (jakarta.persistence.MapKeyJoinColumn)1 UniqueConstraint (jakarta.persistence.UniqueConstraint)1 ArrayList (java.util.ArrayList)1 JaxbJoinTable (org.hibernate.boot.jaxb.mapping.spi.JaxbJoinTable)1