Package org.hibernate.mapping

Examples of org.hibernate.mapping.DependantValue


      LOG.debugf( "Mapping class join: %s -> %s", persistentClass.getEntityName(), join.getTable().getName() );
    }

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

    // join.getKey().setType( new Type( lazz.getIdentifier() ) );
    join.createPrimaryKey();
    join.createForeignKey();
View Full Code Here


          keyVal = collection.getOwner().getIdentifier();
        }
        else {
          keyVal = (KeyValue) collection.getOwner().getRecursiveProperty( propRef ).getValue();
        }
        SimpleValue key = new DependantValue( mappings, collection.getCollectionTable(), keyVal );
        key.setCascadeDeleteEnabled( "cascade"
          .equals( subnode.attributeValue( "on-delete" ) ) );
        bindSimpleValue(
            subnode,
            key,
            collection.isOneToMany(),
View Full Code Here

    join.setPersistentClass( persistentClass );

    //no check constraints available on joins
    join.setTable( originalJoin.getTable() );
    join.setInverse( true );
    SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() );
    //TODO support @ForeignKey
    join.setKey( key );
    join.setSequentialSelect( false );
    //TODO support for inverse and optional
    join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
    key.setCascadeDeleteEnabled( false );
    Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator();
    while ( mappedByColumns.hasNext() ) {
      Column column = (Column) mappedByColumns.next();
      Column copy = new Column();
      copy.setLength( column.getLength() );
      copy.setScale( column.getScale() );
      copy.setValue( key );
      copy.setName( column.getQuotedName() );
      copy.setNullable( column.isNullable() );
      copy.setPrecision( column.getPrecision() );
      copy.setUnique( column.isUnique() );
      copy.setSqlType( column.getSqlType() );
      copy.setCheckConstraint( column.getCheckConstraint() );
      copy.setComment( column.getComment() );
      copy.setDefaultValue( column.getDefaultValue() );
      key.addColumn( copy );
    }
    persistentClass.addJoin( join );
    return join;
  }
View Full Code Here

      onDeleteAppropriate = true;
      final JoinedSubclass jsc = (JoinedSubclass) persistentClass;
      if ( persistentClass.getEntityPersisterClass() == null ) {
        persistentClass.getRootClass().setEntityPersisterClass( JoinedSubclassEntityPersister.class );
      }
      SimpleValue key = new DependantValue( jsc.getTable(), jsc.getIdentifier() );
      jsc.setKey( key );
      ForeignKey fk = annotatedClass.getAnnotation( ForeignKey.class );
      if ( fk != null && !BinderHelper.isDefault( fk.name() ) ) {
        key.setForeignKeyName( fk.name() );
      }
      if ( onDeleteAnn != null ) {
        key.setCascadeDeleteEnabled( OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ) );
      }
      else {
        key.setCascadeDeleteEnabled( false );
      }
      //we are never in a second pass at that stage, so queue it
      SecondPass sp = new JoinedSubclassFkSecondPass( jsc, inheritanceJoinedColumns, key, mappings );
      mappings.addSecondPass( sp );
      mappings.addSecondPass( new CreateKeySecondPass( jsc ) );
View Full Code Here

    else {
      keyVal = (KeyValue) collValue.getOwner()
          .getRecursiveProperty( propRef )
          .getValue();
    }
    DependantValue key = new DependantValue( collValue.getCollectionTable(), keyVal );
    key.setTypeName( null );
    Ejb3Column.checkPropertyConsistency( joinColumns, collValue.getOwnerEntityName() );
    key.setNullable( joinColumns.length == 0 || joinColumns[0].isNullable() );
    key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() );
    key.setCascadeDeleteEnabled( cascadeDeleteEnabled );
    collValue.setKey( key );
    ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
    String fkName = fk != null ? fk.name() : "";
    if ( !BinderHelper.isDefault( fkName ) ) key.setForeignKeyName( fkName );
    return key;
  }
View Full Code Here

  }

  private void bindJoinToPersistentClass(
      Join join, Ejb3JoinColumn[] ejb3JoinColumns
  ) {
    SimpleValue key = new DependantValue( join.getTable(), persistentClass.getIdentifier() );
    join.setKey( key );
    setFKNameIfDefined( join );
    key.setCascadeDeleteEnabled( false );
    TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, mappings );
    join.createPrimaryKey();
    join.createForeignKey();
    persistentClass.addJoin( join );
  }
View Full Code Here

    join.setPersistentClass( persistentClass );

    //no check constraints available on joins
    join.setTable( originalJoin.getTable() );
    join.setInverse( true );
    SimpleValue key = new DependantValue( join.getTable(), persistentClass.getIdentifier() );
    //TODO support @ForeignKey
    join.setKey( key );
    join.setSequentialSelect( false );
    //TODO support for inverse and optional
    join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
    key.setCascadeDeleteEnabled( false );
    Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator();
    while ( mappedByColumns.hasNext() ) {
      Column column = (Column) mappedByColumns.next();
      Column copy = new Column();
      copy.setLength( column.getLength() );
      copy.setScale( column.getScale() );
      copy.setValue( key );
      copy.setName( column.getQuotedName() );
      copy.setNullable( column.isNullable() );
      copy.setPrecision( column.getPrecision() );
      copy.setUnique( column.isUnique() );
      copy.setSqlType( column.getSqlType() );
      copy.setCheckConstraint( column.getCheckConstraint() );
      copy.setComment( column.getComment() );
      copy.setDefaultValue( column.getDefaultValue() );
      key.addColumn( copy );
    }
    persistentClass.addJoin( join );
    return join;
  }
View Full Code Here

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

        " -> " + join.getTable().getName()
      );

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

    // join.getKey().setType( new Type( lazz.getIdentifier() ) );
    join.createPrimaryKey();
    join.createForeignKey();
View Full Code Here

          keyVal = collection.getOwner().getIdentifier();
        }
        else {
          keyVal = (KeyValue) collection.getOwner().getReferencedProperty( propRef ).getValue();
        }
        SimpleValue key = new DependantValue( collection.getCollectionTable(), keyVal );
        key.setCascadeDeleteEnabled( "cascade"
          .equals( subnode.attributeValue( "on-delete" ) ) );
        bindSimpleValue(
            subnode,
            key,
            collection.isOneToMany(),
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.DependantValue

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.