Search in sources :

Example 6 with MapKeyJoinColumn

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

the class Ejb3XmlOneToManyTest method testMultipleMapKeyJoinColumns.

@Test
public void testMultipleMapKeyJoinColumns() throws Exception {
    reader = getReader(Entity3.class, "field1", "one-to-many.orm15.xml");
    assertAnnotationPresent(OneToMany.class);
    assertAnnotationNotPresent(MapKey.class);
    assertAnnotationNotPresent(MapKeyClass.class);
    assertAnnotationNotPresent(MapKeyTemporal.class);
    assertAnnotationNotPresent(MapKeyEnumerated.class);
    assertAnnotationNotPresent(MapKeyColumn.class);
    assertAnnotationPresent(MapKeyJoinColumns.class);
    assertAnnotationNotPresent(MapKeyJoinColumn.class);
    MapKeyJoinColumns joinColumnsAnno = reader.getAnnotation(MapKeyJoinColumns.class);
    MapKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
    assertEquals(2, joinColumns.length);
    assertEquals("", joinColumns[0].name());
    assertEquals("", joinColumns[0].referencedColumnName());
    assertFalse(joinColumns[0].unique());
    assertFalse(joinColumns[0].nullable());
    assertTrue(joinColumns[0].insertable());
    assertTrue(joinColumns[0].updatable());
    assertEquals("", joinColumns[0].columnDefinition());
    assertEquals("", joinColumns[0].table());
    assertEquals("col1", joinColumns[1].name());
    assertEquals("col2", joinColumns[1].referencedColumnName());
    assertTrue(joinColumns[1].unique());
    assertTrue(joinColumns[1].nullable());
    assertFalse(joinColumns[1].insertable());
    assertFalse(joinColumns[1].updatable());
    assertEquals("int", joinColumns[1].columnDefinition());
    assertEquals("table1", joinColumns[1].table());
}
Also used : MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) MapKeyJoinColumns(jakarta.persistence.MapKeyJoinColumns) Test(org.junit.Test)

Example 7 with MapKeyJoinColumn

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

the class Ejb3XmlElementCollectionTest method testMultipleMapKeyJoinColumns.

@Test
public void testMultipleMapKeyJoinColumns() throws Exception {
    reader = getReader(Entity3.class, "field1", "element-collection.orm15.xml");
    assertAnnotationPresent(ElementCollection.class);
    assertAnnotationNotPresent(MapKey.class);
    assertAnnotationNotPresent(MapKeyClass.class);
    assertAnnotationNotPresent(MapKeyTemporal.class);
    assertAnnotationNotPresent(MapKeyEnumerated.class);
    assertAnnotationNotPresent(MapKeyColumn.class);
    assertAnnotationPresent(MapKeyJoinColumns.class);
    assertAnnotationNotPresent(MapKeyJoinColumn.class);
    MapKeyJoinColumns joinColumnsAnno = reader.getAnnotation(MapKeyJoinColumns.class);
    MapKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
    assertEquals(2, joinColumns.length);
    assertEquals("", joinColumns[0].name());
    assertEquals("", joinColumns[0].referencedColumnName());
    assertFalse(joinColumns[0].unique());
    assertFalse(joinColumns[0].nullable());
    assertTrue(joinColumns[0].insertable());
    assertTrue(joinColumns[0].updatable());
    assertEquals("", joinColumns[0].columnDefinition());
    assertEquals("", joinColumns[0].table());
    assertEquals("col1", joinColumns[1].name());
    assertEquals("col2", joinColumns[1].referencedColumnName());
    assertTrue(joinColumns[1].unique());
    assertTrue(joinColumns[1].nullable());
    assertFalse(joinColumns[1].insertable());
    assertFalse(joinColumns[1].updatable());
    assertEquals("int", joinColumns[1].columnDefinition());
    assertEquals("table1", joinColumns[1].table());
}
Also used : MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) MapKeyJoinColumns(jakarta.persistence.MapKeyJoinColumns) Test(org.junit.Test)

Example 8 with MapKeyJoinColumn

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

the class Ejb3XmlManyToManyTest method testSingleMapKeyJoinColumn.

/**
 * When there's a single map key join column, we still wrap it with a
 * MapKeyJoinColumns annotation.
 */
@Test
public void testSingleMapKeyJoinColumn() throws Exception {
    reader = getReader(Entity3.class, "field1", "many-to-many.orm14.xml");
    assertAnnotationPresent(ManyToMany.class);
    assertAnnotationNotPresent(MapKey.class);
    assertAnnotationNotPresent(MapKeyClass.class);
    assertAnnotationNotPresent(MapKeyTemporal.class);
    assertAnnotationNotPresent(MapKeyEnumerated.class);
    assertAnnotationNotPresent(MapKeyColumn.class);
    assertAnnotationPresent(MapKeyJoinColumns.class);
    assertAnnotationNotPresent(MapKeyJoinColumn.class);
    MapKeyJoinColumns joinColumnsAnno = reader.getAnnotation(MapKeyJoinColumns.class);
    MapKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
    assertEquals(1, joinColumns.length);
    assertEquals("col1", joinColumns[0].name());
}
Also used : MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) MapKeyJoinColumns(jakarta.persistence.MapKeyJoinColumns) Test(org.junit.Test)

Example 9 with MapKeyJoinColumn

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

the class Ejb3XmlManyToManyTest method testMultipleMapKeyJoinColumns.

@Test
public void testMultipleMapKeyJoinColumns() throws Exception {
    reader = getReader(Entity3.class, "field1", "many-to-many.orm15.xml");
    assertAnnotationPresent(ManyToMany.class);
    assertAnnotationNotPresent(MapKey.class);
    assertAnnotationNotPresent(MapKeyClass.class);
    assertAnnotationNotPresent(MapKeyTemporal.class);
    assertAnnotationNotPresent(MapKeyEnumerated.class);
    assertAnnotationNotPresent(MapKeyColumn.class);
    assertAnnotationPresent(MapKeyJoinColumns.class);
    assertAnnotationNotPresent(MapKeyJoinColumn.class);
    MapKeyJoinColumns joinColumnsAnno = reader.getAnnotation(MapKeyJoinColumns.class);
    MapKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
    assertEquals(2, joinColumns.length);
    assertEquals("", joinColumns[0].name());
    assertEquals("", joinColumns[0].referencedColumnName());
    assertFalse(joinColumns[0].unique());
    assertFalse(joinColumns[0].nullable());
    assertTrue(joinColumns[0].insertable());
    assertTrue(joinColumns[0].updatable());
    assertEquals("", joinColumns[0].columnDefinition());
    assertEquals("", joinColumns[0].table());
    assertEquals("col1", joinColumns[1].name());
    assertEquals("col2", joinColumns[1].referencedColumnName());
    assertTrue(joinColumns[1].unique());
    assertTrue(joinColumns[1].nullable());
    assertFalse(joinColumns[1].insertable());
    assertFalse(joinColumns[1].updatable());
    assertEquals("int", joinColumns[1].columnDefinition());
    assertEquals("table1", joinColumns[1].table());
}
Also used : MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) MapKeyJoinColumns(jakarta.persistence.MapKeyJoinColumns) Test(org.junit.Test)

Aggregations

MapKeyJoinColumn (jakarta.persistence.MapKeyJoinColumn)9 MapKeyJoinColumns (jakarta.persistence.MapKeyJoinColumns)7 Test (org.junit.Test)6 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)2 JaxbMapKeyJoinColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyJoinColumn)2 Column (jakarta.persistence.Column)1 DiscriminatorColumn (jakarta.persistence.DiscriminatorColumn)1 JoinColumn (jakarta.persistence.JoinColumn)1 MapKeyColumn (jakarta.persistence.MapKeyColumn)1 OrderColumn (jakarta.persistence.OrderColumn)1 PrimaryKeyJoinColumn (jakarta.persistence.PrimaryKeyJoinColumn)1 UniqueConstraint (jakarta.persistence.UniqueConstraint)1 ArrayList (java.util.ArrayList)1 AnnotationException (org.hibernate.AnnotationException)1 AnnotatedDiscriminatorColumn.buildDiscriminatorColumn (org.hibernate.cfg.AnnotatedDiscriminatorColumn.buildDiscriminatorColumn)1 MapKeyColumnDelegator (org.hibernate.cfg.annotations.MapKeyColumnDelegator)1 MapKeyJoinColumnDelegator (org.hibernate.cfg.annotations.MapKeyJoinColumnDelegator)1 Constraint (org.hibernate.mapping.Constraint)1