@Override public Iterator getColumnIterator() { return new JoinedIterator( includedTable.getColumnIterator(), super.getColumnIterator() ); }
public Iterator sqlCommentStrings(Dialect dialect, String defaultCatalog, String defaultSchema) { List comments = new ArrayList(); if ( dialect.supportsCommentOn() ) { String tableName = getQualifiedName( dialect, defaultCatalog, defaultSchema ); if ( comment != null ) { comments.add( "comment on table " + tableName + " is '" + comment + "'" ); } Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); String columnComment = column.getComment(); if ( columnComment != null ) { comments.add( "comment on column " + tableName + '.' + column.getQuotedName( dialect ) + " is '" + columnComment + "'" ); } } } return comments.iterator(); }
protected void applyComments(Table table, QualifiedName tableName, List<String> sqlStrings) { if ( dialect.supportsCommentOn() ) { if ( table.getComment() != null ) { sqlStrings.add( "comment on table " + tableName + " is '" + table.getComment() + "'" ); } final Iterator iter = table.getColumnIterator(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); String columnComment = column.getComment(); if ( columnComment != null ) { sqlStrings.add( "comment on column " + tableName + '.' + column.getQuotedName( dialect ) + " is '" + columnComment + "'" ); } } } }
private Column getColumnByName(Table table, String columnName) { Iterator<Column> columnIterator = table.getColumnIterator(); while ( columnIterator.hasNext() ) { Column column = columnIterator.next(); if ( columnName.equals( column.getName() ) ) { return column; } } return null; } }
protected String buildIdTableCreateStatement(Table idTable, JdbcServices jdbcServices, MetadataImplementor metadata) { final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); StringBuilder buffer = new StringBuilder( getIdTableSupport().getCreateIdTableCommand() ) .append( ' ' ) .append( jdbcEnvironment.getQualifiedObjectNameFormatter().format( idTable.getQualifiedTableName(), dialect ) ) .append( " (" ); Iterator itr = idTable.getColumnIterator(); while ( itr.hasNext() ) { final Column column = (Column) itr.next(); buffer.append( column.getQuotedName( dialect ) ).append( ' ' ); buffer.append( column.getSqlType( dialect, metadata ) ); if ( column.isNullable() ) { buffer.append( dialect.getNullColumnString() ); } else { buffer.append( " not null" ); } if ( itr.hasNext() ) { buffer.append( ", " ); } } buffer.append( ") " ); if ( getIdTableSupport().getCreateIdTableStatementOptions() != null ) { buffer.append( getIdTableSupport().getCreateIdTableStatementOptions() ); } return buffer.toString(); }
@Override public void addColumn(Column column) { final Iterator<Column> columnIterator = getTable().getColumnIterator(); while ( columnIterator.hasNext() ) { final Column next = columnIterator.next(); if ( next.getCanonicalName().equals( column.getCanonicalName() ) ) { next.setNullable( false ); log.debugf( "Forcing column [%s] to be non-null as it is part of the primary key for table [%s]", column.getCanonicalName(), getTableNameForLogging( column ) ); } } super.addColumn( column ); }
@SuppressWarnings("unchecked") public static boolean isColumnPresent(String tableName, String columnName, Metadata metadata) { for ( Table table : metadata.collectTableMappings() ) { if (tableName.equals( table.getName() ) ) { Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator(); while ( columns.hasNext() ) { Column column = columns.next(); if ( columnName.equals( column.getName() ) ) { return true; } } } } return false; }
private boolean isDefaultColumnPresent(String collectionOwner, String propertyName, String suffix) { final Collection collection = metadata().getCollectionBinding( collectionOwner + "." + propertyName ); final Iterator columnIterator = collection.getCollectionTable().getColumnIterator(); boolean hasDefault = false; while ( columnIterator.hasNext() ) { Column column = (Column) columnIterator.next(); if ( (propertyName + suffix).equals( column.getName() ) ) hasDefault = true; } return hasDefault; }
Table table = (Table) titer.next(); if ( !table.isAbstractUnionTable() ) { Iterator citer = table.getColumnIterator(); while ( citer.hasNext() ) { columns.add( citer.next() );
final Iterator selectableItr = table.getColumnIterator(); while ( selectableItr.hasNext() ) { final Selectable selectable = (Selectable) selectableItr.next();
private void isCollectionColumnPresent(String collectionOwner, String propertyName, String columnName) { final Collection collection = metadata().getCollectionBinding( collectionOwner + "." + propertyName ); final Iterator columnIterator = collection.getCollectionTable().getColumnIterator(); boolean hasDefault = false; while ( columnIterator.hasNext() ) { Column column = (Column) columnIterator.next(); if ( columnName.equals( column.getName() ) ) hasDefault = true; } assertTrue( "Could not find " + columnName, hasDefault ); }
.append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList();
Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next();
private void doTestHbmQuoting(Class clazz) { Table table = metadata().getEntityBinding( clazz.getName() ).getTable(); assertTrue( table.isQuoted() ); Iterator itr = table.getColumnIterator(); while(itr.hasNext()) { Column column = (Column) itr.next(); assertTrue( column.isQuoted() ); } }
@SuppressWarnings({"unchecked"}) @Test public void testJoinColumnName() { Iterator<Column> columns = metadata().getEntityBinding( MIDDLE_VERSIONS_ENTITY_NAME ).getTable().getColumnIterator(); boolean id1Found = false; boolean id2Found = false; while ( columns.hasNext() ) { Column column = columns.next(); if ( "VJT_ID".equals( column.getName() ) ) { id1Found = true; } if ( "STR_ID".equals( column.getName() ) ) { id2Found = true; } } assert id1Found && id2Found; } }
@SuppressWarnings({"unchecked"}) @Test public void testJoinColumnName() { Iterator<Column> columns = metadata().getEntityBinding( MIDDLE_VERSIONS_ENTITY_NAME ).getTable().getColumnIterator(); boolean id1Found = false; boolean id2Found = false; while ( columns.hasNext() ) { Column column = columns.next(); if ( "ID_1".equals( column.getName() ) ) { id1Found = true; } if ( "ID_2".equals( column.getName() ) ) { id2Found = true; } } assert id1Found && id2Found; } }
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase(Locale.ROOT) .startsWith( columnInfo.getTypeName().toLowerCase(Locale.ROOT) ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase(Locale.ROOT) + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
/** * Verify that * {@link VersionsJoinTableRangeComponentTestEntity#getComponent3()} is * partially audited. */ @Test public void testOverrideNotAudited() { PersistentClass auditClass = metadata().getEntityBinding( VersionsJoinTableRangeComponentTestEntity.class.getName() + "_AUD" ); assert auditClass != null; @SuppressWarnings({"unchecked"}) Iterator<Column> columns = auditClass.getTable().getColumnIterator(); boolean auditColumn1Found = false; boolean auditColumn2Found = false; while ( columns.hasNext() ) { Column column = columns.next(); if ( "STR1".equals( column.getName() ) ) { auditColumn1Found = true; } if ( "STR2".equals( column.getName() ) ) { auditColumn2Found = true; } } assert auditColumn1Found && !auditColumn2Found; }
@Test public void testJoinColumnNamesComponent1() { PersistentClass auditClass = metadata().getEntityBinding( COMPONENT_1_AUDIT_JOIN_TABLE_NAME ); assert auditClass != null; @SuppressWarnings({"unchecked"}) Iterator<Column> columns = auditClass.getTable().getColumnIterator(); boolean id1Found = false; boolean id2Found = false; while ( columns.hasNext() ) { Column column = columns.next(); if ( "VJTRCTE1_ID".equals( column.getName() ) ) { id1Found = true; } if ( "VJTRTE_ID".equals( column.getName() ) ) { id2Found = true; } } assert id1Found && id2Found; }
@Test public void testJoinColumnNamesComponent2() { PersistentClass auditClass = metadata().getEntityBinding( COMPONENT_2_AUDIT_JOIN_TABLE_NAME ); assert auditClass != null; @SuppressWarnings({"unchecked"}) Iterator<Column> columns = auditClass.getTable().getColumnIterator(); boolean id1Found = false; boolean id2Found = false; while ( columns.hasNext() ) { Column column = columns.next(); if ( "VJTRCTE2_ID".equals( column.getName() ) ) { id1Found = true; } if ( "VJTRTAE_ID".equals( column.getName() ) ) { id2Found = true; } } assert id1Found && id2Found; }