Search in sources :

Example 1 with JaxbColumn

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

the class JPAXMLOverriddenAnnotationReader method buildColumns.

private Columns buildColumns(JaxbColumn element, String nodeName) {
    if (element == null) {
        return null;
    }
    List<Column> columns = new ArrayList<>(1);
    columns.add(getColumn(element, false, nodeName));
    if (columns.size() > 0) {
        AnnotationDescriptor columnsDescr = new AnnotationDescriptor(Columns.class);
        columnsDescr.setValue("columns", columns.toArray(new Column[columns.size()]));
        return AnnotationFactory.create(columnsDescr);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbPrimaryKeyJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn) JaxbMapKeyJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyJoinColumn) PrimaryKeyJoinColumn(jakarta.persistence.PrimaryKeyJoinColumn) JaxbMapKeyColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyColumn) JaxbDiscriminatorColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbDiscriminatorColumn) MapKeyColumn(jakarta.persistence.MapKeyColumn) JaxbColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbColumn) MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) JoinColumn(jakarta.persistence.JoinColumn) OrderColumn(jakarta.persistence.OrderColumn) DiscriminatorColumn(jakarta.persistence.DiscriminatorColumn) JaxbOrderColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumn) Column(jakarta.persistence.Column) JaxbJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumn) ArrayList(java.util.ArrayList)

Example 2 with JaxbColumn

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

the class JPAXMLOverriddenAnnotationReader method buildAttributeOverrides.

private List<AttributeOverride> buildAttributeOverrides(List<JaxbAttributeOverride> subelements, String nodeName) {
    List<AttributeOverride> overrides = new ArrayList<>();
    if (subelements != null && subelements.size() > 0) {
        for (JaxbAttributeOverride current : subelements) {
            AnnotationDescriptor override = new AnnotationDescriptor(AttributeOverride.class);
            copyAttribute(override, "name", current.getName(), true);
            JaxbColumn column = current.getColumn();
            override.setValue("column", getColumn(column, true, nodeName));
            overrides.add(AnnotationFactory.create(override));
        }
    }
    return overrides;
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbAttributeOverride(org.hibernate.boot.jaxb.mapping.spi.JaxbAttributeOverride) ArrayList(java.util.ArrayList) JaxbColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbColumn) JaxbAttributeOverride(org.hibernate.boot.jaxb.mapping.spi.JaxbAttributeOverride) AttributeOverride(jakarta.persistence.AttributeOverride)

Example 3 with JaxbColumn

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

the class JPAXMLOverriddenAnnotationReader method buildColumns.

private Columns buildColumns(List<JaxbColumn> elements, String nodeName) {
    List<Column> columns = new ArrayList<>(elements.size());
    for (JaxbColumn element : elements) {
        columns.add(getColumn(element, false, nodeName));
    }
    if (columns.size() > 0) {
        AnnotationDescriptor columnsDescr = new AnnotationDescriptor(Columns.class);
        columnsDescr.setValue("columns", columns.toArray(new Column[columns.size()]));
        return AnnotationFactory.create(columnsDescr);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbPrimaryKeyJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn) JaxbMapKeyJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyJoinColumn) PrimaryKeyJoinColumn(jakarta.persistence.PrimaryKeyJoinColumn) JaxbMapKeyColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyColumn) JaxbDiscriminatorColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbDiscriminatorColumn) MapKeyColumn(jakarta.persistence.MapKeyColumn) JaxbColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbColumn) MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) JoinColumn(jakarta.persistence.JoinColumn) OrderColumn(jakarta.persistence.OrderColumn) DiscriminatorColumn(jakarta.persistence.DiscriminatorColumn) JaxbOrderColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumn) Column(jakarta.persistence.Column) JaxbJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumn) ArrayList(java.util.ArrayList) JaxbColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbColumn)

Example 4 with JaxbColumn

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

the class JPAXMLOverriddenAnnotationReader method getColumn.

private Column getColumn(JaxbColumn element, boolean isMandatory, String nodeName) {
    if (element != null) {
        AnnotationDescriptor column = new AnnotationDescriptor(Column.class);
        copyAttribute(column, "name", element.getName(), false);
        copyAttribute(column, "unique", element.isUnique(), false);
        copyAttribute(column, "nullable", element.isNullable(), false);
        copyAttribute(column, "insertable", element.isInsertable(), false);
        copyAttribute(column, "updatable", element.isUpdatable(), false);
        copyAttribute(column, "column-definition", element.getColumnDefinition(), false);
        copyAttribute(column, "table", element.getTable(), false);
        copyAttribute(column, "length", element.getLength(), false);
        copyAttribute(column, "precision", element.getPrecision(), false);
        copyAttribute(column, "scale", element.getScale(), false);
        return (Column) AnnotationFactory.create(column);
    } else {
        if (isMandatory) {
            throw new AnnotationException(nodeName + ".column is mandatory. " + SCHEMA_VALIDATION);
        }
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbPrimaryKeyJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn) JaxbMapKeyJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyJoinColumn) PrimaryKeyJoinColumn(jakarta.persistence.PrimaryKeyJoinColumn) JaxbMapKeyColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyColumn) JaxbDiscriminatorColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbDiscriminatorColumn) MapKeyColumn(jakarta.persistence.MapKeyColumn) JaxbColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbColumn) MapKeyJoinColumn(jakarta.persistence.MapKeyJoinColumn) JoinColumn(jakarta.persistence.JoinColumn) OrderColumn(jakarta.persistence.OrderColumn) DiscriminatorColumn(jakarta.persistence.DiscriminatorColumn) JaxbOrderColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumn) Column(jakarta.persistence.Column) JaxbJoinColumn(org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumn) AnnotationException(org.hibernate.AnnotationException)

Aggregations

AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)4 JaxbColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbColumn)4 Column (jakarta.persistence.Column)3 DiscriminatorColumn (jakarta.persistence.DiscriminatorColumn)3 JoinColumn (jakarta.persistence.JoinColumn)3 MapKeyColumn (jakarta.persistence.MapKeyColumn)3 MapKeyJoinColumn (jakarta.persistence.MapKeyJoinColumn)3 OrderColumn (jakarta.persistence.OrderColumn)3 PrimaryKeyJoinColumn (jakarta.persistence.PrimaryKeyJoinColumn)3 ArrayList (java.util.ArrayList)3 JaxbDiscriminatorColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbDiscriminatorColumn)3 JaxbJoinColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumn)3 JaxbMapKeyColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyColumn)3 JaxbMapKeyJoinColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyJoinColumn)3 JaxbOrderColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumn)3 JaxbPrimaryKeyJoinColumn (org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn)3 AttributeOverride (jakarta.persistence.AttributeOverride)1 AnnotationException (org.hibernate.AnnotationException)1 JaxbAttributeOverride (org.hibernate.boot.jaxb.mapping.spi.JaxbAttributeOverride)1