Package org.hibernate.mapping

Examples of org.hibernate.mapping.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 );
View Full Code Here


        PrimaryKey primaryKey = table.getPrimaryKey();
        createConstraint( neo4jDb, table, label, primaryKey );
        @SuppressWarnings("unchecked")
        Iterator<Column> columnIterator = table.getColumnIterator();
        while ( columnIterator.hasNext() ) {
          Column column = columnIterator.next();
          if ( column.isUnique() ) {
            createUniqueConstraintIfMissing( neo4jDb, label, column.getName() );
          }
        }
        Iterator<UniqueKey> uniqueKeyIterator = table.getUniqueKeyIterator();
        while ( uniqueKeyIterator.hasNext() ) {
          createConstraint( neo4jDb, table, label, uniqueKeyIterator.next() );
View Full Code Here

  }

  private void logMultipleColumnsWarning(Table table, Constraint constraint) {
    StringBuilder builder = new StringBuilder();
    for ( Iterator<Column> columnIterator = constraint.getColumnIterator(); columnIterator.hasNext(); ) {
      Column column = columnIterator.next();
      builder.append( ", " );
      builder.append( column.getName() );
    }
    String columns = "[" + builder.substring( 2 ) + "]";
    log.constraintSpanningMultipleColumns( constraint.getName(), table.getName(), columns );
  }
View Full Code Here

        assertNotNull(todaysDate);
        log.debug("today's date: " + todaysDate);
    }

    private Column createColumn(Class clazz) {
        Column column = new Column();
        SimpleValue sv = new SimpleValue();
        sv.setTypeName(clazz.getName());
        column.setValue(sv);
        return column;
    }
View Full Code Here

    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 );
View Full Code Here

        if ( table.isPhysicalTable() ) {
          String tableName = table.getQuotedName();
          // do something with table
          Iterator<Column> columns = table.getColumnIterator();
          while ( columns.hasNext() ) {
            Column column = columns.next();
            String columnName = column.getCanonicalName();
            // do something with column
          }
          //TODO handle unique constraints?
        }
      }
View Full Code Here

                                .create(targetTable), fk.getColumns(), isUnique);
        }

        Iterator columns = fk.getColumnIterator();
        while (columns.hasNext()) {
            Column fkcolumn = (Column) columns.next();
            checkColumn(fkcolumn);
            value.addColumn(fkcolumn);
            processedColumns.add(fkcolumn);
        }
View Full Code Here

    private Property bindManyToOne(String propertyName, boolean mutable, Table table, ForeignKey fk, Set processedColumns) {
        ManyToOne value = new ManyToOne(table);
        value.setReferencedEntityName( fk.getReferencedEntityName() );
    Iterator columns = fk.getColumnIterator();
        while ( columns.hasNext() ) {
      Column fkcolumn = (Column) columns.next();
            checkColumn(fkcolumn);
            value.addColumn(fkcolumn);
            processedColumns.add(fkcolumn);
    }
        value.setFetchMode(FetchMode.SELECT);
View Full Code Here

    SimpleValue keyValue = new DependantValue( collectionTable, referencedKeyValue );
    //keyValue.setForeignKeyName("none"); // Avoid creating the foreignkey
    //key.setCascadeDeleteEnabled( "cascade".equals( subnode.attributeValue("on-delete") ) );
    Iterator columnIterator = foreignKey.getColumnIterator();
    while ( columnIterator.hasNext() ) {
      Column fkcolumn = (Column) columnIterator.next();
      if(fkcolumn.getSqlTypeCode()!=null) { // TODO: user defined foreign ref columns does not have a type set.
        guessAndAlignType(collectionTable, fkcolumn, mapping, false); // needed to ensure foreign key columns has same type as the "property" column.
      }
      keyValue.addColumn( fkcolumn );
    }
View Full Code Here

    else {
      log.debug("No primary key found for " + table + ", using all properties as the identifier.");
      keyColumns = new ArrayList();
      Iterator iter = table.getColumnIterator();
      while (iter.hasNext() ) {
        Column col = (Column) iter.next();
        keyColumns.add(col);
      }
    }

    final TableIdentifier tableIdentifier = TableIdentifier.create(table);

    String tableIdentifierStrategyName = "assigned";

    boolean naturalId;

    if (keyColumns.size()>1) {
      log.debug("id strategy for " + rc.getEntityName() + " since it has a multiple column primary key");
      naturalId = true;

      id = handleCompositeKey(rc, processed, keyColumns, mapping);
      idPropertyname = revengStrategy.tableToIdentifierPropertyName(tableIdentifier);
      if(idPropertyname==null) {
        idPropertyname = "id";
      }
    }
    else {
      pki.suggestedStrategy = revengStrategy.getTableIdentifierStrategyName(tableIdentifier);
      String suggestedStrategy = pki.suggestedStrategy;
      if(suggestedStrategy==null) {
        suggestedStrategy = collector.getSuggestedIdentifierStrategy( tableIdentifier.getCatalog(), tableIdentifier.getSchema(), tableIdentifier.getName() );
        if(suggestedStrategy==null) {
          suggestedStrategy = "assigned";
        }
        tableIdentifierStrategyName = suggestedStrategy;
      } else {
        tableIdentifierStrategyName = suggestedStrategy;
      }

      naturalId = "assigned".equals( tableIdentifierStrategyName );
      Column pkc = (Column) keyColumns.get(0);
      checkColumn(pkc);

      id = bindColumnToSimpleValue(table, pkc, mapping, !naturalId);

      idPropertyname = revengStrategy.tableToIdentifierPropertyName(tableIdentifier);
      if(idPropertyname==null) {
        idPropertyname = revengStrategy.columnToPropertyName(tableIdentifier, pkc.getName() );
      }

      processed.add(pkc);
    }
    id.setIdentifierGeneratorStrategy(tableIdentifierStrategyName);
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.Column

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.