Examples of UniqueKey


Examples of org.hibernate.mapping.UniqueKey

  }

  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

Examples of org.hibernate.mapping.UniqueKey

      }
      else if ( "filter".equals( name ) ) {
        parseFilter( subnode, persistentClass, mappings );
      }
      else if ( "natural-id".equals( name ) ) {
        UniqueKey uk = new UniqueKey();
        uk.setTable(table);
        //by default, natural-ids are "immutable" (constant)
        boolean mutableId = "true".equals( subnode.attributeValue("mutable") );
        createClassProperties(
            subnode,
            persistentClass,
            mappings,
            inheritedMetas,
            uk,
            mutableId,
            false,
            true
          );
        uk.setName( Constraint.generateName( uk.generatedConstraintNamePrefix(),
            table, uk.getColumns() ) );
        table.addUniqueKey(uk);
      }
      else if ( "query".equals(name) ) {
        bindNamedQuery(subnode, persistentClass.getEntityName(), mappings);
      }
View Full Code Here

Examples of org.hibernate.mapping.UniqueKey

      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

Examples of org.hibernate.mapping.UniqueKey

      }
      else if ( "filter".equals( name ) ) {
        parseFilter( subnode, persistentClass, mappings );
      }
      else if ( "natural-id".equals( name ) ) {
        UniqueKey uk = new UniqueKey();
        uk.setName("_UniqueKey");
        uk.setTable(table);
        //by default, natural-ids are "immutable" (constant)
        boolean mutableId = "true".equals( subnode.attributeValue("mutable") );
        createClassProperties(
            subnode,
            persistentClass,
View Full Code Here

Examples of org.hibernate.mapping.UniqueKey

      Table table = (Table) iter.next();
      if ( table.isPhysicalTable() ) {

        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 );
        }


        subIter = table.getIndexIterator();
View Full Code Here

Examples of org.hibernate.mapping.UniqueKey

            tableCatalog, table.isQuoted() );

        if (! constraintMethod.equals( UniqueConstraintSchemaUpdateStrategy.SKIP )) {
          Iterator uniqueIter = table.getUniqueKeyIterator();
          while ( uniqueIter.hasNext() ) {
            final UniqueKey uniqueKey = (UniqueKey) uniqueIter.next();
            // Skip if index already exists. Most of the time, this
            // won't work since most Dialects use Constraints. However,
            // keep it for the few that do use Indexes.
            if ( tableInfo != null && StringHelper.isNotEmpty( uniqueKey.getName() ) ) {
              final IndexMetadata meta = tableInfo.getIndexMetadata( uniqueKey.getName() );
              if ( meta != null ) {
                continue;
              }
            }
            String constraintString = uniqueKey.sqlCreateString( dialect, mapping, tableCatalog, tableSchema );
            if ( constraintString != null && !constraintString.isEmpty() )
              if ( constraintMethod.equals( UniqueConstraintSchemaUpdateStrategy.DROP_RECREATE_QUIETLY ) ) {
                String constraintDropString = uniqueKey.sqlDropString( dialect, tableCatalog, tableSchema );
                scripts.add( new SchemaUpdateScript( constraintDropString, true) );
              }
              scripts.add( new SchemaUpdateScript( constraintString, true) );
          }
        }
View Full Code Here

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

Examples of org.hibernate.mapping.UniqueKey

      }
      else if ( "filter".equals( name ) ) {
        parseFilter( subnode, persistentClass, mappings );
      }
      else if ( "natural-id".equals( name ) ) {
        UniqueKey uk = new UniqueKey();
        uk.setName("_UniqueKey");
        uk.setTable(table);
        //by default, natural-ids are "immutable" (constant)
        boolean mutableId = "true".equals( subnode.attributeValue("mutable") );
        createClassProperties(
            subnode,
            persistentClass,
View Full Code Here

Examples of org.hibernate.mapping.UniqueKey

      }
      else if ( "filter".equals( name ) ) {
        parseFilter( subnode, persistentClass, mappings );
      }
      else if ( "natural-id".equals( name ) ) {
        UniqueKey uk = new UniqueKey();
        uk.setName("_UniqueKey");
        uk.setTable(table);
        //by default, natural-ids are "immutable" (constant)
        boolean mutableId = "true".equals( subnode.attributeValue("mutable") );
        createClassProperties(
            subnode,
            persistentClass,
View Full Code Here

Examples of org.hibernate.mapping.UniqueKey

      Table table = (Table) iter.next();
      if ( table.isPhysicalTable() ) {

        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 );
        }


        subIter = table.getIndexIterator();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.