Package org.hibernate.metamodel.relational

Examples of org.hibernate.metamodel.relational.Column


            .seekEntityBinding()
            .locateTable( valueSource.getContainingTableName() );

        if ( ColumnSource.class.isInstance( valueSource ) ) {
          final ColumnSource columnSource = ColumnSource.class.cast( valueSource );
          final Column column = makeColumn( (ColumnSource) valueSource, table );
          valueBindings.add(
              new SimpleValueBinding(
                  column,
                  columnSource.isIncludedInInsert(),
                  columnSource.isIncludedInUpdate()
              )
          );
        }
        else {
          valueBindings.add(
              new SimpleValueBinding(
                  makeDerivedValue( ( (DerivedValueSource) valueSource ), table )
              )
          );
        }
      }
    }
    else {
      String name = metadata.getOptions()
          .getNamingStrategy()
          .propertyToColumnName( attributeBinding.getAttribute().getName() );
      name = quoteIdentifier( name );
      Column column = attributeBinding.getContainer()
                  .seekEntityBinding()
                  .getPrimaryTable()
                  .locateOrCreateColumn( name );
      column.setNullable( relationalValueSourceContainer.areValuesNullableByDefault() );
      valueBindings.add(
          new SimpleValueBinding(
              column,
              relationalValueSourceContainer.areValuesIncludedInInsertByDefault(),
              relationalValueSourceContainer.areValuesIncludedInUpdateByDefault()
View Full Code Here


  private Column makeColumn(ColumnSource columnSource, TableSpecification table) {
    String name = columnSource.getName();
    name = metadata.getOptions().getNamingStrategy().columnName( name );
    name = quoteIdentifier( name );
    final Column column = table.locateOrCreateColumn( name );
    column.setNullable( columnSource.isNullable() );
    column.setDefaultValue( columnSource.getDefaultValue() );
    column.setSqlType( columnSource.getSqlType() );
    column.setSize( columnSource.getSize() );
    column.setDatatype( columnSource.getDatatype() );
    column.setReadFragment( columnSource.getReadFragment() );
    column.setWriteFragment( columnSource.getWriteFragment() );
    column.setUnique( columnSource.isUnique() );
    column.setCheckCondition( columnSource.getCheckCondition() );
    column.setComment( columnSource.getComment() );
    return column;
  }
View Full Code Here

      LOG.noColumnsSpecifiedForIndex( indexName, table.toLoggableString() );
      return;
    }
    org.hibernate.metamodel.relational.Index index = table.getOrCreateIndex( indexName );
    for ( String columnName : columnNames ) {
      Column column = findColumn( table, columnName );
      if ( column == null ) {
        throw new AnnotationException( "@Index references a unknown column: " + columnName );
      }
      index.addColumn( column );
    }
View Full Code Here

      index.addColumn( column );
    }
  }

  private static Column findColumn(Table table, String columnName) {
    Column column = null;
    for ( SimpleValue value : table.values() ) {
      if ( value instanceof Column && ( (Column) value ).getColumnName().getName().equals( columnName ) ) {
        column = (Column) value;
        break;
      }
View Full Code Here

      LOG.noColumnsSpecifiedForIndex( indexName, table.toLoggableString() );
      return;
    }
    org.hibernate.metamodel.relational.Index index = table.getOrCreateIndex( indexName );
    for ( String columnName : columnNames ) {
      Column column = findColumn( table, columnName );
      if ( column == null ) {
        throw new AnnotationException( "@Index references a unknown column: " + columnName );
      }
      index.addColumn( column );
    }
View Full Code Here

      index.addColumn( column );
    }
  }

  private static Column findColumn(Table table, String columnName) {
    Column column = null;
    for ( SimpleValue value : table.values() ) {
      if ( value instanceof Column && ( (Column) value ).getColumnName().getName().equals( columnName ) ) {
        column = (Column) value;
        break;
      }
View Full Code Here

  public boolean isNullable() {
    for ( SimpleValue simpleValue : getValues() ) {
      if ( simpleValue instanceof DerivedValue ) {
        return true;
      }
      Column column = (Column) simpleValue;
      if ( column.isNullable() ) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

          final String explicitName = columnElement.attributeValue( "name" );
          final String logicalColumnName = getNamingStrategy().logicalColumnName( explicitName, propertyPath );
          final String columnName = getNamingStrategy().columnName( explicitName );
// todo : find out the purpose of these logical bindings
//        mappings.addColumnBinding( logicalColumnName, column, table );
          Column column = table.createColumn( columnName );
          value = column;
          basicColumnBinding( columnElement, column, isNullableByDefault );

          propertyUniqueKeyBinder.bindColumn( column );
          propertyIndexBinder.bindColumn( column );
          new UniqueKeyBinder( columnElement.attribute( "unique-key" ), table ).bindColumn( column );
          new IndexBinder( columnElement.attribute( "index" ), table ).bindColumn( column );
        }
        else if ( "formula".equals( valueElement.getName() ) ) {
          value = table.createDerivedValue( valueElement.getTextTrim() );
        }
      }

// todo : logical 1-1 handling
//      final Attribute uniqueAttribute = node.attribute( "unique" );
//      if ( uniqueAttribute != null
//          && "true".equals( uniqueAttribute.getValue() )
//          && ManyToOne.class.isInstance( simpleValue ) ) {
//        ( (ManyToOne) simpleValue ).markAsLogicalOneToOne();
//      }

      if ( tuple != null ) {
        return tuple;
      }
      else if ( value != null ) {
        return value;
      }
      else if ( autoColumnCreation  ) {
        final String columnName = getNamingStrategy().propertyToColumnName( propertyPath );
        final String logicalColumnName = getNamingStrategy().logicalColumnName( null, propertyPath );
// todo : find out the purpose of these logical bindings
//        mappings.addColumnBinding( logicalColumnName, column, table );
        Column column = table.createColumn( columnName );
        basicColumnBinding( propertyElement, column, isNullableByDefault );
        propertyUniqueKeyBinder.bindColumn( column );
        propertyIndexBinder.bindColumn( column );
        return column;
      }
    }

    if ( propertyElement.elementIterator( "column" ).hasNext() ) {
      throw new MappingException( "column attribute may not be used together with <column> subelement" );
    }

    if ( propertyElement.elementIterator( "formula" ).hasNext() ) {
      throw new MappingException( "column attribute may not be used together with <formula> subelement" );
    }

    final String explicitName = columnAttribute.getValue();
    final String logicalColumnName = getNamingStrategy().logicalColumnName( explicitName, propertyPath );
    final String columnName = getNamingStrategy().columnName( explicitName );
// todo : find out the purpose of these logical bindings
//    mappings.addColumnBinding( logicalColumnName, column, table );
    Column column = table.createColumn( columnName );
    basicColumnBinding( propertyElement, column, isNullableByDefault );
    propertyUniqueKeyBinder.bindColumn( column );
    propertyIndexBinder.bindColumn( column );
    return column;
  }
View Full Code Here

      throw new IllegalArgumentException( "columnName must be non-null." );
    }
        if( state.isGloballyQuotedIdentifiers()){
            columnName = StringHelper.quote( columnName );
        }
    Column value = table.getOrCreateColumn( columnName );
    value.initialize( state, forceNonNullable, forceUnique );
    return value;
  }
View Full Code Here

  public boolean isNullable() {
    for ( SimpleValue simpleValue : getValues() ) {
      if ( simpleValue instanceof DerivedValue ) {
        return true;
      }
      Column column = (Column) simpleValue;
      if ( column.isNullable() ) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.relational.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.