private boolean isSameAsPrimaryKeyColumns(UniqueKey uniqueKey) { if ( primaryKey == null || ! primaryKey.columnIterator().hasNext() ) { // happens for many-to-many tables return false; } return primaryKey.getColumns().containsAll( uniqueKey.getColumns() ) && uniqueKey.getColumns().containsAll( primaryKey.getColumns() ); }
public void addColumn(Column column) { Column old = getColumn( column ); if ( old == null ) { if ( primaryKey != null ) { for ( Column c : primaryKey.getColumns() ) { if ( c.getCanonicalName().equals( column.getCanonicalName() ) ) { column.setNullable( false ); log.debugf( "Forcing column [%s] to be non-null as it is part of the primary key for table [%s]", column.getCanonicalName(), getNameIdentifier().getCanonicalName() ); } } } this.columns.put( column.getCanonicalName(), column ); column.uniqueInteger = this.columns.size(); } else { column.uniqueInteger = old.uniqueInteger; } }
public boolean matches(ForeignKey fk) { if ( refTable.equalsIgnoreCase( fk.getReferencedTable().getName() ) ) { if ( fk.getColumnSpan() == references.size() ) { List fkRefs; if ( fk.isReferenceToPrimaryKey() ) { fkRefs = fk.getReferencedTable().getPrimaryKey().getColumns(); } else { fkRefs = fk.getReferencedColumns(); } for ( int i = 0; i < fk.getColumnSpan(); i++ ) { Column column = fk.getColumn( i ); Column ref = ( Column ) fkRefs.get( i ); if ( !hasReference( column, ref ) ) { return false; } } return true; } } return false; }
Column pkColumn = (Column) table.getPrimaryKey().getColumns().iterator().next(); pkColName = pkColumn.getQuotedName( dialect );
if ( pk==null || pk.getColumns().size() != table.getColumnSpan() ) return false;
if ( pk==null || pk.getColumns().size() != table.getColumnSpan() ) return false;
public boolean isOneToOne(ForeignKey foreignKey) { if(settings.getDetectOneToOne()) { // add support for non-PK associations List<Column> fkColumns = foreignKey.getColumns(); List<Column> pkForeignTableColumns = null; if (foreignKey.getTable().hasPrimaryKey()) pkForeignTableColumns = foreignKey.getTable().getPrimaryKey().getColumns(); boolean equals = fkColumns != null && pkForeignTableColumns != null && fkColumns.size() == pkForeignTableColumns.size(); Iterator<Column> columns = foreignKey.getColumnIterator(); while (equals && columns.hasNext()) { Column fkColumn = (Column) columns.next(); equals = equals && pkForeignTableColumns.contains(fkColumn); } return equals; } else { return false; } }
public boolean isOneToOne(ForeignKey foreignKey) { if(settings.getDetectOneToOne()) { // add support for non-PK associations List<Column> fkColumns = foreignKey.getColumns(); List<Column> pkForeignTableColumns = null; if (foreignKey.getTable().hasPrimaryKey()) pkForeignTableColumns = foreignKey.getTable().getPrimaryKey().getColumns(); boolean equals = fkColumns != null && pkForeignTableColumns != null && fkColumns.size() == pkForeignTableColumns.size(); Iterator<Column> columns = foreignKey.getColumnIterator(); while (equals && columns.hasNext()) { Column fkColumn = (Column) columns.next(); equals = equals && pkForeignTableColumns.contains(fkColumn); } return equals; } else { return false; } }
protected String generateAnnTableUniqueConstraint(Table table) { Iterator<UniqueKey> uniqueKeys = table.getUniqueKeyIterator(); List<String> cons = new ArrayList<String>(); while ( uniqueKeys.hasNext() ) { UniqueKey key = (UniqueKey) uniqueKeys.next(); if (table.hasPrimaryKey() && table.getPrimaryKey().getColumns().equals(key.getColumns())) { continue; } AnnotationBuilder constraint = AnnotationBuilder.createAnnotation( importType("javax.persistence.UniqueConstraint") ); constraint.addQuotedAttributes( "columnNames", new IteratorTransformer<Column>(key.getColumnIterator()) { public String transform(Column column) { return column.getName(); } }); cons.add( constraint.getResult() ); } AnnotationBuilder builder = AnnotationBuilder.createAnnotation( "dummyAnnotation" ); builder.addAttributes( "dummyAttribute", cons.iterator() ); String attributeAsString = builder.getAttributeAsString( "dummyAttribute" ); return attributeAsString==null?"":attributeAsString; }
protected String generateAnnTableUniqueConstraint(Table table) { Iterator<UniqueKey> uniqueKeys = table.getUniqueKeyIterator(); List<String> cons = new ArrayList<String>(); while ( uniqueKeys.hasNext() ) { UniqueKey key = (UniqueKey) uniqueKeys.next(); if (table.hasPrimaryKey() && table.getPrimaryKey().getColumns().equals(key.getColumns())) { continue; } AnnotationBuilder constraint = AnnotationBuilder.createAnnotation( importType("javax.persistence.UniqueConstraint") ); constraint.addQuotedAttributes( "columnNames", new IteratorTransformer<Column>(key.getColumnIterator()) { public String transform(Column column) { return column.getName(); } }); cons.add( constraint.getResult() ); } AnnotationBuilder builder = AnnotationBuilder.createAnnotation( "dummyAnnotation" ); builder.addAttributes( "dummyAttribute", cons.iterator() ); String attributeAsString = builder.getAttributeAsString( "dummyAttribute" ); return attributeAsString==null?"":attributeAsString; }
public boolean matches(ForeignKey fk) { if ( refTable.equalsIgnoreCase( fk.getReferencedTable().getName() ) ) { if ( fk.getColumnSpan() == references.size() ) { List fkRefs; if ( fk.isReferenceToPrimaryKey() ) { fkRefs = fk.getReferencedTable().getPrimaryKey().getColumns(); } else { fkRefs = fk.getReferencedColumns(); } for ( int i = 0; i < fk.getColumnSpan(); i++ ) { Column column = fk.getColumn( i ); Column ref = ( Column ) fkRefs.get( i ); if ( !hasReference( column, ref ) ) { return false; } } return true; } } return false; }
public boolean matches(ForeignKey fk) { if ( refTable.equalsIgnoreCase( fk.getReferencedTable().getName() ) ) { if ( fk.getColumnSpan() == references.size() ) { List fkRefs; if ( fk.isReferenceToPrimaryKey() ) { fkRefs = fk.getReferencedTable().getPrimaryKey().getColumns(); } else { fkRefs = fk.getReferencedColumns(); } for ( int i = 0; i < fk.getColumnSpan(); i++ ) { Column column = fk.getColumn( i ); Column ref = ( Column ) fkRefs.get( i ); if ( !hasReference( column, ref ) ) { return false; } } return true; } } return false; }
for ( Object columnObject : tableMetadata.getPrimaryKey().getColumns() ) { Column column = (Column) columnObject; keyColumnNames.add( column.getName() );
@Override public Association getAssociation(AssociationKey key, AssociationContext associationContext) { Table tableMetadata = provider.getMetaDataCache().get( key.getTable() ); List<Column> tablePKCols = tableMetadata.getPrimaryKey().getColumns(); for ( Object column : tableMetadata.getPrimaryKey().getColumns() ) { String name = ( (Column) column ).getName(); if ( ! combinedKeys.contains( name ) ) {
for ( Object pkColumn : table.getPrimaryKey().getColumns() ) { primaryKeys.add( ( (Column) pkColumn ).getName() );
for (Object hibernateColumn : hibernatePrimaryKey.getColumns()) { pk.getColumns().add(new Column(((org.hibernate.mapping.Column) hibernateColumn).getName()).setRelation(table));
|| (owner.getPrimaryKey() != null && owner.getPrimaryKey().getColumns().contains(mappedColumn)); column.setIsNullable(!notNull);
for (Object column : hibernateReferencedTable.getPrimaryKey().getColumns()) { fk.addPrimaryKeyColumn(new liquibase.structure.core.Column(((org.hibernate.mapping.Column) column).getName()));
for ( Column pkColumn : table.getPrimaryKey().getColumns() ) { String name = pkColumn.getName();
if (hibernatePrimaryKey != null) { boolean isPrimaryKeyColumn = false; for (org.hibernate.mapping.Column pkColumn : (java.util.List<org.hibernate.mapping.Column>) hibernatePrimaryKey.getColumns()) { if (pkColumn.getName().equals(hibernateColumn.getName())) { isPrimaryKeyColumn = true;