Package org.hibernate.mapping

Examples of org.hibernate.mapping.UniqueKey


    if ( StringHelper.isEmpty( keyName ) ) {
      keyName = Constraint.generateName( "UK_", table, columns );
    }
    keyName = normalizer.normalizeIdentifierQuoting( keyName );
   
    UniqueKey uk = table.getOrCreateUniqueKey( keyName );
    for ( Column column : columns ) {
      if ( table.containsColumn( column ) ) {
        uk.addColumn( column );
        unbound.remove( column );
      }
    }
    if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
      StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
View Full Code Here


      }
    }
  }

  private void buildUniqueKeyFromColumnNames(String[] columnNames, Table table, String keyName) {
    UniqueKey uc;
    int size = columnNames.length;
    Column[] columns = new Column[size];
    Set<Column> unbound = new HashSet<Column>();
    Set<Column> unboundNoLogical = new HashSet<Column>();
    ExtendedMappings mappings = createExtendedMappings();
    for (int index = 0; index < size; index++) {
      String columnName;
      try {
        columnName = mappings.getPhysicalColumnName( columnNames[index], table );
        columns[index] = new Column( columnName );
        unbound.add( columns[index] );
        //column equals and hashcode is based on column name
      }
      catch (MappingException e) {
        unboundNoLogical.add( new Column( columnNames[index] ) );
      }
    }
    for (Column column : columns) {
      if ( table.containsColumn( column ) ) {
        uc = table.getOrCreateUniqueKey( keyName );
        uc.addColumn( table.getColumn( column ) );
        unbound.remove( column );
      }
    }
    if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
      StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
View Full Code Here

      if ( table.isPhysicalTable() ) {

        if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) {
          Iterator subIter = table.getUniqueKeyIterator();
          while ( subIter.hasNext() ) {
            UniqueKey uk = (UniqueKey) subIter.next();
            String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema );
            if (constraintString != null) script.add( constraintString );
          }
        }

View Full Code Here

  }

  private void buildUniqueKeyFromColumnNames(Table table, String keyName, String[] columnNames) {
    keyName = normalizer.normalizeIdentifierQuoting( keyName );

    UniqueKey uc;
    int size = columnNames.length;
    Column[] columns = new Column[size];
    Set<Column> unbound = new HashSet<Column>();
    Set<Column> unboundNoLogical = new HashSet<Column>();
    for ( int index = 0; index < size; index++ ) {
      final String logicalColumnName = normalizer.normalizeIdentifierQuoting( columnNames[index] );
      try {
        final String columnName = createMappings().getPhysicalColumnName( logicalColumnName, table );
        columns[index] = new Column( columnName );
        unbound.add( columns[index] );
        //column equals and hashcode is based on column name
      }
      catch ( MappingException e ) {
        unboundNoLogical.add( new Column( logicalColumnName ) );
      }
    }
    for ( Column column : columns ) {
      if ( table.containsColumn( column ) ) {
        uc = table.getOrCreateUniqueKey( keyName );
        uc.addColumn( table.getColumn( column ) );
        unbound.remove( column );
      }
    }
    if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
      StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
View Full Code Here

  private void buildUniqueKeyFromColumnNames(Table table, String keyName, String[] columnNames) {
    ExtendedMappings mappings = createExtendedMappings();
    keyName = mappings.getObjectNameNormalizer().normalizeIdentifierQuoting( keyName );

    UniqueKey uc;
    int size = columnNames.length;
    Column[] columns = new Column[size];
    Set<Column> unbound = new HashSet<Column>();
    Set<Column> unboundNoLogical = new HashSet<Column>();
    for ( int index = 0; index < size; index++ ) {
      final String logicalColumnName = mappings.getObjectNameNormalizer()
          .normalizeIdentifierQuoting( columnNames[index] );
      try {
        final String columnName = mappings.getPhysicalColumnName( logicalColumnName, table );
        columns[index] = new Column( columnName );
        unbound.add( columns[index] );
        //column equals and hashcode is based on column name
      }
      catch ( MappingException e ) {
        unboundNoLogical.add( new Column( logicalColumnName ) );
      }
    }
    for ( Column column : columns ) {
      if ( table.containsColumn( column ) ) {
        uc = table.getOrCreateUniqueKey( keyName );
        uc.addColumn( table.getColumn( column ) );
        unbound.remove( column );
      }
    }
    if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
      StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
View Full Code Here

      if ( table.isPhysicalTable() ) {

        if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) {
          Iterator subIter = table.getUniqueKeyIterator();
          while ( subIter.hasNext() ) {
            UniqueKey uk = (UniqueKey) subIter.next();
            String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema );
            if (constraintString != null) script.add( constraintString );
          }
        }

View Full Code Here

  }

  private void buildUniqueKeyFromColumnNames(Table table, String keyName, String[] columnNames) {
    keyName = normalizer.normalizeIdentifierQuoting( keyName );

    UniqueKey uc;
    int size = columnNames.length;
    Column[] columns = new Column[size];
    Set<Column> unbound = new HashSet<Column>();
    Set<Column> unboundNoLogical = new HashSet<Column>();
    for ( int index = 0; index < size; index++ ) {
      final String logicalColumnName = normalizer.normalizeIdentifierQuoting( columnNames[index] );
      try {
        final String columnName = createMappings().getPhysicalColumnName( logicalColumnName, table );
        columns[index] = new Column( columnName );
        unbound.add( columns[index] );
        //column equals and hashcode is based on column name
      }
      catch ( MappingException e ) {
        unboundNoLogical.add( new Column( logicalColumnName ) );
      }
    }
    for ( Column column : columns ) {
      if ( table.containsColumn( column ) ) {
        uc = table.getOrCreateUniqueKey( keyName );
        uc.addColumn( table.getColumn( column ) );
        unbound.remove( column );
      }
    }
    if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
      StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
View Full Code Here

  public void testUniqueKey() {
   
    Table table = getTable(identifier("withIndex") );
   
    UniqueKey uniqueKey = table.getUniqueKey(identifier("otherIdx") );
    assertNotNull(uniqueKey);
   
    assertEquals(1, uniqueKey.getColumnSpan() );
   
    Column keyCol = uniqueKey.getColumn(0);
    assertTrue(keyCol.isUnique() );
   
    assertSame(keyCol, table.getColumn(keyCol) );
   
  }
View Full Code Here

      }
    }
  }

  private void buildUniqueKeyFromColumnNames(String[] columnNames, Table table, String keyName) {
    UniqueKey uc;
    int size = columnNames.length;
    Column[] columns = new Column[size];
    Set<Column> unbound = new HashSet<Column>();
    Set<Column> unboundNoLogical = new HashSet<Column>();
    ExtendedMappings mappings = createExtendedMappings();
    for ( int index = 0; index < size; index++ ) {
      String columnName;
      try {
        columnName = mappings.getPhysicalColumnName( columnNames[index], table );
        columns[index] = new Column( columnName );
        unbound.add( columns[index] );
        //column equals and hashcode is based on column name
      }
      catch ( MappingException e ) {
        unboundNoLogical.add( new Column( columnNames[index] ) );
      }
    }
    for ( Column column : columns ) {
      if ( table.containsColumn( column ) ) {
        uc = table.getOrCreateUniqueKey( keyName );
        uc.addColumn( table.getColumn( column ) );
        unbound.remove( column );
      }
    }
    if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
      StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
View Full Code Here

      if ( table.isPhysicalTable() ) {

        if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) {
          Iterator subIter = table.getUniqueKeyIterator();
          while ( subIter.hasNext() ) {
            UniqueKey uk = (UniqueKey) subIter.next();
            String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema );
            if (constraintString != null) script.add( constraintString );
          }
        }

View Full Code Here

TOP

Related Classes of org.hibernate.mapping.UniqueKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.