Search in sources :

Example 6 with Selectable

use of org.hibernate.mapping.Selectable in project hibernate-orm by hibernate.

the class LegacyJpaNamingWithAnnotationBindingTests method validateCustomerHqAddressComponent.

@Override
protected void validateCustomerHqAddressComponent(Component component) {
    assertEquals(3, component.getColumnSpan());
    Iterator<Selectable> selectables = component.getColumnIterator();
    int pass = 1;
    while (selectables.hasNext()) {
        final Column column = assertTyping(Column.class, selectables.next());
        if (pass == 1) {
            assertEquals("line1", column.getQuotedName());
        } else if (pass == 2) {
            assertEquals("line2", column.getQuotedName());
        } else if (pass == 3) {
            assertEquals("zipCode_id", column.getQuotedName());
        }
        pass++;
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable) Column(org.hibernate.mapping.Column)

Example 7 with Selectable

use of org.hibernate.mapping.Selectable in project hibernate-orm by hibernate.

the class LegacyJpaNamingWithHbmBindingTests method validateCustomerAddressesElementComponent.

@Override
protected void validateCustomerAddressesElementComponent(Component component) {
    assertEquals(3, component.getColumnSpan());
    Iterator<Selectable> selectables = component.getColumnIterator();
    int pass = 1;
    while (selectables.hasNext()) {
        final Column column = assertTyping(Column.class, selectables.next());
        if (pass == 1) {
            assertEquals("line1", column.getQuotedName());
        } else if (pass == 2) {
            assertEquals("line2", column.getQuotedName());
        } else if (pass == 3) {
            assertEquals("zipCode", column.getQuotedName());
        }
        pass++;
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable) Column(org.hibernate.mapping.Column)

Example 8 with Selectable

use of org.hibernate.mapping.Selectable in project hibernate-orm by hibernate.

the class CollectionMetadataGenerator method searchMappedByKey.

@SuppressWarnings({ "unchecked" })
private String searchMappedByKey(PersistentClass referencedClass, Collection collectionValue) {
    final Iterator<Value> assocIdClassProps = referencedClass.getKeyClosureIterator();
    while (assocIdClassProps.hasNext()) {
        final Value value = assocIdClassProps.next();
        // make sure its a 'Component' because IdClass is registered as this type.
        if (value instanceof Component) {
            final Component component = (Component) value;
            final Iterator<Property> componentPropertyIterator = component.getPropertyIterator();
            while (componentPropertyIterator.hasNext()) {
                final Property property = componentPropertyIterator.next();
                final Iterator<Selectable> propertySelectables = property.getValue().getColumnIterator();
                final Iterator<Selectable> collectionSelectables = collectionValue.getKey().getColumnIterator();
                if (Tools.iteratorsContentEqual(propertySelectables, collectionSelectables)) {
                    return property.getName();
                }
            }
        }
    }
    return null;
}
Also used : Selectable(org.hibernate.mapping.Selectable) Value(org.hibernate.mapping.Value) Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property)

Example 9 with Selectable

use of org.hibernate.mapping.Selectable in project hibernate-orm by hibernate.

the class AbstractSchemaValidator method validateTable.

protected void validateTable(Table table, TableInformation tableInformation, Metadata metadata, ExecutionOptions options, Dialect dialect) {
    if (tableInformation == null) {
        throw new SchemaManagementException(String.format("Schema-validation: missing table [%s]", table.getQualifiedTableName().toString()));
    }
    final Iterator selectableItr = table.getColumnIterator();
    while (selectableItr.hasNext()) {
        final Selectable selectable = (Selectable) selectableItr.next();
        if (Column.class.isInstance(selectable)) {
            final Column column = (Column) selectable;
            final ColumnInformation existingColumn = tableInformation.getColumn(Identifier.toIdentifier(column.getQuotedName()));
            if (existingColumn == null) {
                throw new SchemaManagementException(String.format("Schema-validation: missing column [%s] in table [%s]", column.getName(), table.getQualifiedTableName()));
            }
            validateColumnType(table, column, existingColumn, metadata, options, dialect);
        }
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable) Column(org.hibernate.mapping.Column) SchemaManagementException(org.hibernate.tool.schema.spi.SchemaManagementException) ColumnInformation(org.hibernate.tool.schema.extract.spi.ColumnInformation) Iterator(java.util.Iterator)

Example 10 with Selectable

use of org.hibernate.mapping.Selectable in project hibernate-orm by hibernate.

the class LegacyJpaNamingWithHbmBindingTests method validateCustomerHqAddressComponent.

@Override
protected void validateCustomerHqAddressComponent(Component component) {
    assertEquals(3, component.getColumnSpan());
    Iterator<Selectable> selectables = component.getColumnIterator();
    int pass = 1;
    while (selectables.hasNext()) {
        final Column column = assertTyping(Column.class, selectables.next());
        if (pass == 1) {
            assertEquals("line1", column.getQuotedName());
        } else if (pass == 2) {
            assertEquals("line2", column.getQuotedName());
        } else if (pass == 3) {
            assertEquals("zipCode", column.getQuotedName());
        }
        pass++;
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable) Column(org.hibernate.mapping.Column)

Aggregations

Selectable (org.hibernate.mapping.Selectable)11 Column (org.hibernate.mapping.Column)8 Property (org.hibernate.mapping.Property)5 Iterator (java.util.Iterator)3 AnnotationException (org.hibernate.AnnotationException)3 Component (org.hibernate.mapping.Component)3 SimpleValue (org.hibernate.mapping.SimpleValue)3 Value (org.hibernate.mapping.Value)2 Random (java.util.Random)1 JoinColumn (javax.persistence.JoinColumn)1 MapKeyJoinColumn (javax.persistence.MapKeyJoinColumn)1 PrimaryKeyJoinColumn (javax.persistence.PrimaryKeyJoinColumn)1 AssertionFailure (org.hibernate.AssertionFailure)1 XProperty (org.hibernate.annotations.common.reflection.XProperty)1 EntityNaming (org.hibernate.boot.model.naming.EntityNaming)1 Identifier (org.hibernate.boot.model.naming.Identifier)1 ImplicitJoinColumnNameSource (org.hibernate.boot.model.naming.ImplicitJoinColumnNameSource)1 ImplicitNamingStrategy (org.hibernate.boot.model.naming.ImplicitNamingStrategy)1 ImplicitPrimaryKeyJoinColumnNameSource (org.hibernate.boot.model.naming.ImplicitPrimaryKeyJoinColumnNameSource)1 PhysicalNamingStrategy (org.hibernate.boot.model.naming.PhysicalNamingStrategy)1