Package org.hibernate.mapping

Examples of org.hibernate.mapping.Table


        String compositeIdName = revengStrategy.tableToCompositeIdName(TableIdentifier.create(rc.getTable()));
        if(compositeIdName==null) {
          compositeIdName = revengStrategy.classNameToCompositeIdName(rc.getClassName());
        }
        pkc.setComponentClassName(compositeIdName);
    Table table = rc.getTable();
        List list = null;
    if (cfg.preferBasicCompositeIds() ) {
            list = new ArrayList(keyColumns);
        }
    else {
            list = findForeignKeys(table.getForeignKeyIterator(), keyColumns);
        }
        for (Iterator iter = list.iterator(); iter.hasNext();) {
            Object element = iter.next();
      Property property;
            if (element instanceof Column) {
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

    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();

    Table table = mappings.addTable(
        schema,
        catalog,
        getClassTableName( entity, node, schema, catalog, null, mappings ),
        getSubselect( node ),
            entity.isAbstract() != null && entity.isAbstract().booleanValue()
      );
    entity.setTable( table );
    bindComment(table, node);

    log.info(
        "Mapping class: " + entity.getEntityName() +
        " -> " + entity.getTable().getName()
      );

    // MUTABLE
    Attribute mutableNode = node.attribute( "mutable" );
    entity.setMutable( ( mutableNode == null ) || mutableNode.getValue().equals( "true" ) );

    // WHERE
    Attribute whereNode = node.attribute( "where" );
    if ( whereNode != null ) entity.setWhere( whereNode.getValue() );

    // CHECK
    Attribute chNode = node.attribute( "check" );
    if ( chNode != null ) table.addCheckConstraint( chNode.getValue() );

    // POLYMORPHISM
    Attribute polyNode = node.attribute( "polymorphism" );
    entity.setExplicitPolymorphism( ( polyNode != null )
      && polyNode.getValue().equals( "explicit" ) );

    // ROW ID
    Attribute rowidNode = node.attribute( "rowid" );
    if ( rowidNode != null ) table.setRowId( rowidNode.getValue() );

    Iterator subnodes = node.elementIterator();
    while ( subnodes.hasNext() ) {

      Element subnode = (Element) subnodes.next();
View Full Code Here

    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();

    Table denormalizedSuperTable = unionSubclass.getSuperclass().getTable();
    Table mytable = mappings.addDenormalizedTable(
        schema,
        catalog,
        getClassTableName(unionSubclass, node, schema, catalog, denormalizedSuperTable, mappings ),
            unionSubclass.isAbstract() != null && unionSubclass.isAbstract().booleanValue(),
        getSubselect( node ),
View Full Code Here

    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();

    Table mytable = mappings.addTable(
        schema,
        catalog,
        getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ),
        getSubselect( node ),
        false
      );
    joinedSubclass.setTable( mytable );
    bindComment(mytable, node);

    log.info(
        "Mapping joined-subclass: " + joinedSubclass.getEntityName() +
        " -> " + joinedSubclass.getTable().getName()
      );

    // KEY
    Element keyNode = node.element( "key" );
    SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() );
    joinedSubclass.setKey( key );
    key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
    bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings );

    // model.getKey().setType( new Type( model.getIdentifier() ) );
    joinedSubclass.createPrimaryKey();
    joinedSubclass.createForeignKey();

    // CHECK
    Attribute chNode = node.attribute( "check" );
    if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() );

    // properties
    createClassProperties( node, joinedSubclass, mappings, inheritedMetas );

  }
View Full Code Here

    String schema = schemaNode == null ?
        mappings.getSchemaName() : schemaNode.getValue();
    Attribute catalogNode = node.attribute( "catalog" );
    String catalog = catalogNode == null ?
        mappings.getCatalogName() : catalogNode.getValue();
    Table primaryTable = persistentClass.getTable();
    Table table = mappings.addTable(
        schema,
        catalog,
        getClassTableName( persistentClass, node, schema, catalog, primaryTable, mappings ),
        getSubselect( node ),
        false
View Full Code Here

    joinSpan = persistentClass.getJoinClosureSpan()+1;
    qualifiedTableNames = new String[joinSpan];
    isInverseTable = new boolean[joinSpan];
    isNullableTable = new boolean[joinSpan];
    keyColumnNames = new String[joinSpan][];
    final Table table = persistentClass.getRootTable();
    qualifiedTableNames[0] = table.getQualifiedName(
        factory.getDialect(),
        factory.getSettings().getDefaultCatalogName(),
        factory.getSettings().getDefaultSchemaName()
    );
    isInverseTable[0] = false;
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.getName() ) == null && (
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Table

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.