List of usage examples for org.hibernate.mapping SimpleValue getColumnIterator
@Override
public Iterator<Selectable> getColumnIterator()
From source file:com.oy.shared.lm.ext.HBMCtoGRAPH.java
License:Open Source License
private Attribute addSimpleProp(SimpleValue val, String name) { if (!val.isSimpleValue()) { throw new RuntimeException("Expected SimpleValue."); }/*from ww w. ja va 2 s .c o m*/ Attribute attr = new Attribute(); attr.name = name; if (attr.name == null) { Iterator iter = val.getColumnIterator(); while (iter.hasNext()) { Column col = (Column) iter.next(); attr.name = col.getName(); break; } } if (val instanceof Component) { attr.type = ((Component) val).getComponentClassName(); } else { attr.type = val.getType().getName(); } return attr; }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected Column getColumnForSimpleValue(SimpleValue element) { return (Column) element.getColumnIterator().next(); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
/** * Creates and binds the discriminator property used in table-per-hierarchy inheritance to * discriminate between sub class instances * * @param table The table to bind onto * @param entity The root class entity * @param mappings The mappings instance *//*from w w w .ja v a 2 s . co m*/ protected void bindDiscriminatorProperty(Table table, RootClass entity, Mappings mappings) { Mapping m = getMapping(entity.getMappedClass()); SimpleValue d = new SimpleValue(mappings, table); entity.setDiscriminator(d); entity.setDiscriminatorValue( m != null && m.getDiscriminator() != null ? m.getDiscriminator() : entity.getClassName()); if (m != null && m.getDiscriminatorMap().get("insert") != null) { entity.setDiscriminatorInsertable((Boolean) m.getDiscriminatorMap().get("insert")); } if (m != null && m.getDiscriminatorMap().get("type") != null) { d.setTypeName((String) m.getDiscriminatorMap().get("type")); } if (m != null && m.getDiscriminatorMap().get("formula") != null) { Formula formula = new Formula(); formula.setFormula((String) m.getDiscriminatorMap().get("formula")); d.addFormula(formula); } else { bindSimpleValue(STRING_TYPE, d, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings); ColumnConfig cc = m == null ? null : m.getDiscriminatorColumn(); if (cc != null) { Column c = (Column) d.getColumnIterator().next(); if (cc.getName() != null) { c.setName(cc.getName()); } bindColumnConfigToColumn(c, cc); } } entity.setPolymorphic(true); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
private static Column getColumnForSimpleValue(SimpleValue element) { return (Column) element.getColumnIterator().next(); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
/** * Creates and binds the discriminator property used in table-per-hierarchy inheritance to * discriminate between sub class instances * * @param table The table to bind onto * @param entity The root class entity * @param mappings The mappings instance *//* w w w . j a va 2 s . co m*/ private static void bindDiscriminatorProperty(Table table, RootClass entity, Mappings mappings) { Mapping m = getMapping(entity.getMappedClass()); SimpleValue d = new SimpleValue(mappings, table); entity.setDiscriminator(d); entity.setDiscriminatorValue( m != null && m.getDiscriminator() != null ? m.getDiscriminator() : entity.getClassName()); if (m != null && m.getDiscriminatorMap().get("insert") != null) { entity.setDiscriminatorInsertable((Boolean) m.getDiscriminatorMap().get("insert")); } if (m != null && m.getDiscriminatorMap().get("type") != null) { d.setTypeName((String) m.getDiscriminatorMap().get("type")); } if (m != null && m.getDiscriminatorMap().get("formula") != null) { Formula formula = new Formula(); formula.setFormula((String) m.getDiscriminatorMap().get("formula")); d.addFormula(formula); } else { bindSimpleValue(STRING_TYPE, d, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings); ColumnConfig cc = m == null ? null : m.getDiscriminatorColumn(); if (cc != null) { Column c = (Column) d.getColumnIterator().next(); if (cc.getName() != null) { c.setName(cc.getName()); } bindColumnConfigToColumn(c, cc); } } entity.setPolymorphic(true); }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
/** * Creates and binds the discriminator property used in table-per-hierarchy inheritance to * discriminate between sub class instances * * @param table The table to bind onto * @param entity The root class entity * @param mappings The mappings instance */// w w w . j ava 2 s .c o m protected void bindDiscriminatorProperty(Table table, RootClass entity, Mappings mappings) { Mapping m = getMapping(entity.getMappedClass()); SimpleValue d = new SimpleValue(mappings, table); entity.setDiscriminator(d); entity.setDiscriminatorValue( m != null && m.getDiscriminator() != null ? m.getDiscriminator() : entity.getClassName()); if (m != null && m.getDiscriminatorMap().get("insert") != null) { entity.setDiscriminatorInsertable((Boolean) m.getDiscriminatorMap().get("insert")); } if (m != null && m.getDiscriminatorMap().get("type") != null) { d.setTypeName((String) m.getDiscriminatorMap().get("type")); } if (m != null && m.getDiscriminatorMap().get("formula") != null) { Formula formula = new Formula(); formula.setFormula((String) m.getDiscriminatorMap().get("formula")); d.addFormula(formula); } else { bindSimpleValue(STRING_TYPE, d, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings); ColumnConfig cc = m == null ? null : m.getDiscriminatorColumn(); if (cc != null) { Column c = (Column) d.getColumnIterator().next(); if (cc.getName() != null) { c.setName(cc.getName()); } bindColumnConfigToColumn(null, c, cc); } } entity.setPolymorphic(true); }
From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
/** * Creates and binds the discriminator property used in table-per-hierarchy inheritance to * discriminate between sub class instances * * @param table The table to bind onto * @param entity The root class entity * @param mappings The mappings instance *//*from ww w .j a v a2 s . c om*/ protected void bindDiscriminatorProperty(Table table, RootClass entity, InFlightMetadataCollector mappings) { Mapping m = getMapping(entity.getMappedClass()); SimpleValue d = new SimpleValue(mappings, table); entity.setDiscriminator(d); DiscriminatorConfig discriminatorConfig = m != null ? m.getDiscriminator() : null; boolean hasDiscriminatorConfig = discriminatorConfig != null; entity.setDiscriminatorValue( hasDiscriminatorConfig ? discriminatorConfig.getValue() : entity.getClassName()); if (hasDiscriminatorConfig) { if (discriminatorConfig.getInsertable() != null) { entity.setDiscriminatorInsertable(discriminatorConfig.getInsertable()); } Object type = discriminatorConfig.getType(); if (type != null) { if (type instanceof Class) { d.setTypeName(((Class) type).getName()); } else { d.setTypeName(type.toString()); } } } if (hasDiscriminatorConfig && discriminatorConfig.getFormula() != null) { Formula formula = new Formula(); formula.setFormula(discriminatorConfig.getFormula()); d.addFormula(formula); } else { bindSimpleValue(STRING_TYPE, d, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME, mappings); ColumnConfig cc = !hasDiscriminatorConfig ? null : discriminatorConfig.getColumn(); if (cc != null) { Column c = (Column) d.getColumnIterator().next(); if (cc.getName() != null) { c.setName(cc.getName()); } bindColumnConfigToColumn(null, c, cc); } } entity.setPolymorphic(true); }