Package org.hibernate.metamodel.relational

Examples of org.hibernate.metamodel.relational.ForeignKey


    buildForeignKey();
  }

  private void buildForeignKey() {
    // TODO: move this stuff to relational model
    ForeignKey foreignKey = getValue().getTable()
        .createForeignKey( referencedAttributeBinding.getValue().getTable(), foreignKeyName );
    Iterator<SimpleValue> referencingValueIterator = getValues().iterator();
    Iterator<SimpleValue> targetValueIterator = referencedAttributeBinding.getValues().iterator();
    while ( referencingValueIterator.hasNext() ) {
      if ( !targetValueIterator.hasNext() ) {
        // TODO: improve this message
        throw new MappingException(
            "number of values in many-to-one reference is greater than number of values in target"
        );
      }
      SimpleValue referencingValue = referencingValueIterator.next();
      SimpleValue targetValue = targetValueIterator.next();
      if ( Column.class.isInstance( referencingValue ) ) {
        if ( !Column.class.isInstance( targetValue ) ) {
          // TODO improve this message
          throw new MappingException( "referencing value is a column, but target is not a column" );
        }
        foreignKey.addColumnMapping( Column.class.cast( referencingValue ), Column.class.cast( targetValue ) );
      }
      else if ( Column.class.isInstance( targetValue ) ) {
        // TODO: improve this message
        throw new MappingException( "referencing value is not a column, but target is a column." );
      }
View Full Code Here


    buildForeignKey();
  }

  private void buildForeignKey() {
    // TODO: move this stuff to relational model
    ForeignKey foreignKey = getTable().createForeignKeyreferencedAttributeBinding.getTable(), foreignKeyName );
    Iterator<SimpleValue> referencingValueIterator = getValues().iterator();
    Iterator<SimpleValue> targetValueIterator =  referencedAttributeBinding.getValues().iterator();
    while ( referencingValueIterator.hasNext() ) {
      if ( ! targetValueIterator.hasNext() ) {
        // TODO: improve this message
        throw new MappingException( "number of values in many-to-one reference is greater than number of values in target" );
      }
      SimpleValue referencingValue = referencingValueIterator.next();
      SimpleValue targetValue = targetValueIterator.next();
      if ( Column.class.isInstance( referencingValue ) ) {
        if ( ! Column.class.isInstance( targetValue ) ) {
          // TODO improve this message
          throw new MappingException( "referencing value is a column, but target is not a column" );
        }
        foreignKey.addColumnMapping( Column.class.cast( referencingValue ), Column.class.cast( targetValue ) );
      }
      else if ( Column.class.isInstance( targetValue ) ) {
        // TODO: improve this message
        throw new MappingException( "referencing value is not a column, but target is a column." );
      }
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.relational.ForeignKey

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.