Package org.hibernate.mapping

Examples of org.hibernate.mapping.Table$ForeignKeyKey


      name = getObjectNameNormalizer().normalizeIdentifierQuoting( name );
      schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema );
      catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog );

      String key = subselect == null ? Table.qualify( catalog, schema, name ) : subselect;
      Table table = ( Table ) tables.get( key );

      if ( table == null ) {
        table = new Table();
        table.setAbstract( isAbstract );
        table.setName( name );
        table.setSchema( schema );
        table.setCatalog( catalog );
        table.setSubselect( subselect );
        tables.put( key, table );
      }
      else {
        if ( !isAbstract ) {
          table.setAbstract( false );
        }
      }

      return table;
    }
View Full Code Here


      String key = subselect == null ? Table.qualify(catalog, schema, name) : subselect;
      if ( tables.containsKey( key ) ) {
        throw new DuplicateMappingException( "table", name );
      }

      Table table = new DenormalizedTable( includedTable );
      table.setAbstract( isAbstract );
      table.setName( name );
      table.setSchema( schema );
      table.setCatalog( catalog );
      table.setSubselect( subselect );

      tables.put( key, table );
      return table;
    }
View Full Code Here

    }

    public String getPhysicalColumnName(String logicalName, Table table) throws MappingException {
      logicalName = logicalName.toLowerCase();
      String finalName = null;
      Table currentTable = table;
      do {
        TableColumnNameBinding binding = ( TableColumnNameBinding ) columnNameBindingPerTable.get( currentTable );
        if ( binding != null ) {
          finalName = ( String ) binding.logicalToPhysical.get( logicalName );
        }
        String key = buildTableNameKey(
            currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName()
        );
        TableDescription description = ( TableDescription ) tableNameBinding.get( key );
        if ( description != null ) {
          currentTable = description.denormalizedSupertable;
        }
View Full Code Here

      return finalName;
    }

    public String getLogicalColumnName(String physicalName, Table table) throws MappingException {
      String logical = null;
      Table currentTable = table;
      TableDescription description = null;
      do {
        TableColumnNameBinding binding = ( TableColumnNameBinding ) columnNameBindingPerTable.get( currentTable );
        if ( binding != null ) {
          logical = ( String ) binding.physicalToLogical.get( physicalName );
        }
        String key = buildTableNameKey(
            currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName()
        );
        description = ( TableDescription ) tableNameBinding.get( key );
        if ( description != null ) {
          currentTable = description.denormalizedSupertable;
        }
View Full Code Here

    }

    if ( dialect.dropConstraints() ) {
      Iterator iter = getTableMappings();
      while ( iter.hasNext() ) {
        Table table = (Table) iter.next();
        if ( table.isPhysicalTable() ) {
          Iterator subIter = table.getForeignKeyIterator();
          while ( subIter.hasNext() ) {
            ForeignKey fk = (ForeignKey) subIter.next();
            if ( fk.isPhysicalConstraint() ) {
              script.add(
                  fk.sqlDropString(
                      dialect,
                      defaultCatalog,
                      defaultSchema
                    )
                );
            }
          }
        }
      }
    }


    Iterator iter = getTableMappings();
    while ( iter.hasNext() ) {

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

        /*Iterator subIter = table.getIndexIterator();
        while ( subIter.hasNext() ) {
          Index index = (Index) subIter.next();
          if ( !index.isForeignKey() || !dialect.hasImplicitIndexForForeignKey() ) {
            script.add( index.sqlDropString(dialect) );
          }
        }*/

        script.add(
            table.sqlDropString(
                dialect,
                defaultCatalog,
                defaultSchema
              )
          );
 
View Full Code Here

    String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
    String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );

    Iterator iter = getTableMappings();
    while ( iter.hasNext() ) {
      Table table = (Table) iter.next();
      if ( table.isPhysicalTable() ) {
        script.add(
            table.sqlCreateString(
                dialect,
                mapping,
                defaultCatalog,
                defaultSchema
              )
          );
        Iterator comments = table.sqlCommentStrings( dialect, defaultCatalog, defaultSchema );
        while ( comments.hasNext() ) {
          script.add( comments.next() );
        }
      }
    }

    iter = getTableMappings();
    while ( iter.hasNext() ) {
      Table table = (Table) iter.next();
      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 );
          }
        }


        Iterator subIter = table.getIndexIterator();
        while ( subIter.hasNext() ) {
          Index index = (Index) subIter.next();
          script.add(
              index.sqlCreateString(
                  dialect,
                  mapping,
                  defaultCatalog,
                  defaultSchema
                )
            );
        }

        if ( dialect.hasAlterTable() ) {
          subIter = table.getForeignKeyIterator();
          while ( subIter.hasNext() ) {
            ForeignKey fk = (ForeignKey) subIter.next();
            if ( fk.isPhysicalConstraint() ) {
              script.add(
                  fk.sqlCreateString(
View Full Code Here

    ArrayList script = new ArrayList( 50 );

    Iterator iter = getTableMappings();
    while ( iter.hasNext() ) {
      Table table = (Table) iter.next();
      if ( table.isPhysicalTable() ) {
       
        TableMetadata tableInfo = databaseMetadata.getTableMetadata(
            table.getName(),
            ( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
            ( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
                table.isQuoted()

          );
        if ( tableInfo == null ) {
          script.add(
              table.sqlCreateString(
                  dialect,
                  mapping,
                  defaultCatalog,
                  defaultSchema
                )
            );
        }
        else {
          Iterator subiter = table.sqlAlterStrings(
              dialect,
              mapping,
              tableInfo,
              defaultCatalog,
              defaultSchema
            );
          while ( subiter.hasNext() ) {
            script.add( subiter.next() );
          }
        }

        Iterator comments = table.sqlCommentStrings( dialect, defaultCatalog, defaultSchema );
        while ( comments.hasNext() ) {
          script.add( comments.next() );
        }

      }
    }

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

        TableMetadata tableInfo = databaseMetadata.getTableMetadata(
            table.getName(),
            table.getSchema(),
            table.getCatalog(),
            table.isQuoted()
          );

        if ( dialect.hasAlterTable() ) {
          Iterator subIter = table.getForeignKeyIterator();
          while ( subIter.hasNext() ) {
            ForeignKey fk = (ForeignKey) subIter.next();
            if ( fk.isPhysicalConstraint() ) {
              boolean create = tableInfo == null || (
                  tableInfo.getForeignKeyMetadata( fk ) == null && (
                      //Icky workaround for MySQL bug:
                      !( dialect instanceof MySQLDialect ) ||
                          tableInfo.getIndexMetadata( fk.getName() ) == null
                    )
                );
              if ( create ) {
                script.add(
                    fk.sqlCreateString(
                        dialect,
                        mapping,
                        defaultCatalog,
                        defaultSchema
                      )
                  );
              }
            }
          }
        }

        Iterator subIter = table.getIndexIterator();
        while ( subIter.hasNext() ) {
          final Index index = (Index) subIter.next();
          // Skip if index already exists
          if ( tableInfo != null && StringHelper.isNotEmpty( index.getName() ) ) {
            final IndexMetadata meta = tableInfo.getIndexMetadata( index.getName() );
View Full Code Here

    String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
    String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
   
    Iterator iter = getTableMappings();
    while ( iter.hasNext() ) {
      Table table = (Table) iter.next();
      if ( table.isPhysicalTable() ) {
       

        TableMetadata tableInfo = databaseMetadata.getTableMetadata(
            table.getName(),
            ( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
            ( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
                table.isQuoted());
        if ( tableInfo == null ) {
          throw new HibernateException( "Missing table: " + table.getName() );
        }
        else {
          table.validateColumns( dialect, mapping, tableInfo );
        }

      }
    }
View Full Code Here

    return false;
  }

   public boolean isTable(Object key) throws HibernateException {
     if(key instanceof String) {
      Table tbl = new Table((String)key);
      if ( getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null ) {
         return true;
       } else {
         String[] strings = StringHelper.split(".", (String) key);
         if(strings.length==3) {
          tbl = new Table(strings[2]);
          tbl.setCatalog(strings[0]);
          tbl.setSchema(strings[1]);
          return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
         } else if (strings.length==2) {
          tbl = new Table(strings[1]);
          tbl.setSchema(strings[0]);
          return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
         }
       }
     }
     return false;
   }
View Full Code Here

    ownerPersister = factory.getEntityPersister(entityName);
    queryLoaderName = collection.getLoaderName();
    nodeName = collection.getNodeName();
    isMutable = collection.isMutable();

    Table table = collection.getCollectionTable();
    fetchMode = collection.getElement().getFetchMode();
    elementType = collection.getElement().getType();
    //isSet = collection.isSet();
    //isSorted = collection.isSorted();
    isPrimitiveArray = collection.isPrimitiveArray();
    isArray = collection.isArray();
    subselectLoadable = collection.isSubselectLoadable();
   
    qualifiedTableName = table.getQualifiedName(
        dialect,
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
      );
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Table$ForeignKeyKey

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.