Search in sources :

Example 1 with Selectable

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

the class MetadataTools method addColumns.

public static void addColumns(Element anyMapping, Iterator selectables) {
    while (selectables.hasNext()) {
        final Selectable selectable = (Selectable) selectables.next();
        if (selectable.isFormula()) {
            throw new FormulaNotSupportedException();
        }
        addColumn(anyMapping, (Column) selectable);
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable)

Example 2 with Selectable

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

the class LegacyJpaNamingWithAnnotationBindingTests 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_id", column.getQuotedName());
        }
        pass++;
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable) Column(org.hibernate.mapping.Column)

Example 3 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 4 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 5 with Selectable

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

the class AbstractEntityPersister method internalInitSubclassPropertyAliasesMap.

private void internalInitSubclassPropertyAliasesMap(String path, Iterator propertyIterator) {
    while (propertyIterator.hasNext()) {
        Property prop = (Property) propertyIterator.next();
        String propname = path == null ? prop.getName() : path + "." + prop.getName();
        if (prop.isComposite()) {
            Component component = (Component) prop.getValue();
            Iterator compProps = component.getPropertyIterator();
            internalInitSubclassPropertyAliasesMap(propname, compProps);
        } else {
            String[] aliases = new String[prop.getColumnSpan()];
            String[] cols = new String[prop.getColumnSpan()];
            Iterator colIter = prop.getColumnIterator();
            int l = 0;
            while (colIter.hasNext()) {
                Selectable thing = (Selectable) colIter.next();
                aliases[l] = thing.getAlias(getFactory().getDialect(), prop.getValue().getTable());
                // TODO: skip formulas?
                cols[l] = thing.getText(getFactory().getDialect());
                l++;
            }
            subclassPropertyAliases.put(propname, aliases);
            subclassPropertyColumnNames.put(propname, cols);
        }
    }
}
Also used : Selectable(org.hibernate.mapping.Selectable) Iterator(java.util.Iterator) Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property)

Aggregations

Selectable (org.hibernate.mapping.Selectable)17 Column (org.hibernate.mapping.Column)14 Property (org.hibernate.mapping.Property)5 ConstraintDescriptor (javax.validation.metadata.ConstraintDescriptor)4 SimpleValue (org.hibernate.mapping.SimpleValue)4 Iterator (java.util.Iterator)3 AnnotationException (org.hibernate.AnnotationException)3 Component (org.hibernate.mapping.Component)3 Value (org.hibernate.mapping.Value)3 MapKeyColumn (javax.persistence.MapKeyColumn)2 MapKeyJoinColumn (javax.persistence.MapKeyJoinColumn)2 AssertionFailure (org.hibernate.AssertionFailure)2 Ejb3Column (org.hibernate.cfg.Ejb3Column)2 Ejb3JoinColumn (org.hibernate.cfg.Ejb3JoinColumn)2 DependantValue (org.hibernate.mapping.DependantValue)2 OneToMany (org.hibernate.mapping.OneToMany)2 PersistentClass (org.hibernate.mapping.PersistentClass)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Random (java.util.Random)1