@Override public int getColumnSpan() { int n=0; Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property p = (Property) iter.next(); n+= p.getColumnSpan(); } return n; }
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() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
boolean found = false; for (Property property : columnsToProperty.get( column ) ) { if ( property.getColumnSpan() == 1 ) { orderedProperties.add( property ); found = true;
thisClassProperties.add( prop ); int span = prop.getColumnSpan(); propertyColumnSpans[i] = span; propertySubclassNames[i] = prop.getPersistentClass().getEntityName(); String[] cols = new String[prop.getColumnSpan()]; String[] readers = new String[prop.getColumnSpan()]; String[] readerTemplates = new String[prop.getColumnSpan()]; String[] forms = new String[prop.getColumnSpan()]; int[] colnos = new int[prop.getColumnSpan()]; int[] formnos = new int[prop.getColumnSpan()]; int l = 0; Boolean lazy = Boolean.valueOf( prop.isLazy() && lazyAvailable );
if ( subStrategy.getReferencedColumnValues().length != subProperty.getColumnSpan() ) { throw new ValueGenerationStrategyException( "Internal error : mismatch between number of collected 'referenced column values'" + columnValues, columnIndex, subProperty.getColumnSpan() );
protected void validateZipCode(Metadata metadata) { final PersistentClass zipCodeBinding = metadata.getEntityBinding( ZipCode.class.getName() ); assertNotNull( zipCodeBinding ); validateZipCodePrimaryTableName( zipCodeBinding.getTable().getQuotedName() ); assertEquals( 1, zipCodeBinding.getIdentifier().getColumnSpan() ); validateZipCodePrimaryKeyColumn( (Column) zipCodeBinding.getIdentifier().getColumnIterator().next() ); final Property codeBinding = zipCodeBinding.getProperty( "code" ); assertNotNull( codeBinding ); assertEquals( 1, codeBinding.getColumnSpan() ); validateZipCodeCodeColumn( (Column) codeBinding.getColumnIterator().next() ); final Property cityBinding = zipCodeBinding.getProperty( "city" ); assertNotNull( cityBinding ); assertEquals( 1, cityBinding.getColumnSpan() ); validateZipCodeCityColumn( (Column) cityBinding.getColumnIterator().next() ); final Property stateBinding = zipCodeBinding.getProperty( "state" ); assertNotNull( stateBinding ); assertEquals( 1, stateBinding.getColumnSpan() ); validateZipCodeStateColumn( (Column) stateBinding.getColumnIterator().next() ); }
protected void validateOrder(Metadata metadata) { final PersistentClass orderBinding = metadata.getEntityBinding( Order.class.getName() ); assertNotNull( orderBinding ); validateOrderPrimaryTableName( orderBinding.getTable().getQuotedName() ); assertEquals( 1, orderBinding.getIdentifier().getColumnSpan() ); validateOrderPrimaryKeyColumn( (Column) orderBinding.getIdentifier().getColumnIterator().next() ); final Property referenceCodeBinding = orderBinding.getProperty( "referenceCode" ); assertNotNull( referenceCodeBinding ); assertEquals( 1, referenceCodeBinding.getColumnSpan() ); validateOrderReferenceCodeColumn( (Column) referenceCodeBinding.getColumnIterator().next() ); final Property placedBinding = orderBinding.getProperty( "placed" ); assertNotNull( placedBinding ); assertEquals( 1, placedBinding.getColumnSpan() ); validateOrderPlacedColumn( (Column) placedBinding.getColumnIterator().next() ); final Property fulfilledBinding = orderBinding.getProperty( "fulfilled" ); assertNotNull( fulfilledBinding ); assertEquals( 1, fulfilledBinding.getColumnSpan() ); validateOrderFulfilledColumn( (Column) fulfilledBinding.getColumnIterator().next() ); final Property customerBinding = orderBinding.getProperty( "customer" ); assertNotNull( customerBinding ); assertEquals( 1, customerBinding.getColumnSpan() ); validateOrderCustomerColumn( (Column) customerBinding.getColumnIterator().next() ); }
protected void validateCustomer(Metadata metadata) { final PersistentClass customerBinding = metadata.getEntityBinding( Customer.class.getName() ); assertNotNull( customerBinding ); validateCustomerPrimaryTableName( customerBinding.getTable().getQuotedName() ); assertEquals( 1, customerBinding.getIdentifier().getColumnSpan() ); validateCustomerPrimaryKeyColumn( (Column) customerBinding.getIdentifier().getColumnIterator().next() ); assertNotNull( customerBinding.getVersion() ); assertEquals( 1, customerBinding.getVersion().getColumnSpan() ); validateCustomerVersionColumn( (Column) customerBinding.getVersion().getColumnIterator().next() ); final Property nameBinding = customerBinding.getProperty( "name" ); assertNotNull( nameBinding ); assertEquals( 1, nameBinding.getColumnSpan() ); validateCustomerNameColumn( (Column) nameBinding.getColumnIterator().next() ); final Property hqAddressBinding = customerBinding.getProperty( "hqAddress" ); assertNotNull( hqAddressBinding ); assertEquals( 3, hqAddressBinding.getColumnSpan() ); validateCustomerHqAddressComponent( assertTyping( Component.class, hqAddressBinding.getValue() ) ); }
boolean found = false; for (Property property : columnsToProperty.get( column ) ) { if ( property.getColumnSpan() == 1 ) { orderedProperties.add( property ); found = true;
public int getColumnSpan() { int n=0; Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property p = (Property) iter.next(); n+= p.getColumnSpan(); } return n; } public Iterator getColumnIterator() {
public int getColumnSpan() { int n=0; Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property p = (Property) iter.next(); n+= p.getColumnSpan(); } return n; } public Iterator getColumnIterator() {
public int getColumnSpan() { int n=0; Iterator iter = getPropertyIterator(); while ( iter.hasNext() ) { Property p = (Property) iter.next(); n+= p.getColumnSpan(); } return n; } public Iterator getColumnIterator() {
if ( property.getColumnSpan() == 1 ) { Selectable selectable = (Selectable) property.getColumnIterator().next(); buildColumnAnnotation( selectable, annotations, insertable, updatable );
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( prop.getValue().getTable() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
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() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
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() ); cols[l] = thing.getText( getFactory().getDialect() ); // TODO: skip formulas? l++; } subclassPropertyAliases.put( propname, aliases ); subclassPropertyColumnNames.put( propname, cols ); } } }
span = property.getColumnSpan(); columnIterator = property.getColumnIterator();
span = property.getColumnSpan(); columnIterator = property.getColumnIterator();
@Test public void testCompositeUserDefinedForeignKeys() { Table table = HibernateUtil.getTable(metadata, JdbcUtil.toIdentifier(this, "CHILDREN") ); Iterator<?> foreignKeyIterator = table.getForeignKeyIterator(); ForeignKey fk = (ForeignKey) foreignKeyIterator.next(); Assert.assertEquals(fk.getReferencedTable().getName(), JdbcUtil.toIdentifier(this, "PARENT") ); Assert.assertEquals(2, fk.getReferencedColumns().size()); Assert.assertEquals("child_to_parent", fk.getName()); PersistentClass classMapping = metadata.getEntityBinding("Children"); Property property = classMapping.getProperty("propertyParent"); Assert.assertEquals(2,property.getColumnSpan()); classMapping = metadata.getEntityBinding("Parent"); property = classMapping.getProperty("propertyChildren"); }
Assert.assertEquals("CustomOID", ((Component)sv).getComponentClassName()); Assert.assertEquals(2,classMapping.getIdentifierProperty().getColumnSpan());