Package org.hibernate.mapping

Examples of org.hibernate.mapping.ManyToOne


      else {
        mapKeyType = property.getMapKey().getName();
      }
      PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( mapKeyType );
      boolean isIndexOfEntities = collectionEntity != null;
      ManyToOne element = null;
      org.hibernate.mapping.Map mapValue = (org.hibernate.mapping.Map) this.collection;
      if ( isIndexOfEntities ) {
        element = new ManyToOne( mapValue.getCollectionTable() );
        mapValue.setIndex( element );
        element.setReferencedEntityName( mapKeyType );
        //element.setFetchMode( fetchMode );
        //element.setLazy( fetchMode != FetchMode.JOIN );
        //make the second join non lazy
        element.setFetchMode( FetchMode.JOIN );
        element.setLazy( false );
        //does not make sense for a map key element.setIgnoreNotFound( ignoreNotFound );
      }
      else {
        XClass elementClass;
        AnnotatedClassType classType;
View Full Code Here


    }
    else if ( value instanceof SimpleValue ) {
      SimpleValue sourceValue = (SimpleValue) value;
      SimpleValue targetValue;
      if ( value instanceof ManyToOne ) {
        ManyToOne sourceManyToOne = (ManyToOne) sourceValue;
        ManyToOne targetManyToOne = new ManyToOne( collection.getCollectionTable() );
        targetManyToOne.setFetchMode( FetchMode.DEFAULT );
        targetManyToOne.setLazy( true );
        //targetValue.setIgnoreNotFound( ); does not make sense for a map key
        targetManyToOne.setReferencedEntityName( sourceManyToOne.getReferencedEntityName() );
        targetValue = targetManyToOne;
      }
      else {
        targetValue = new SimpleValue( collection.getCollectionTable() );
        targetValue.setTypeName( sourceValue.getTypeName() );
View Full Code Here

        if (collectionValue.getElement() instanceof OneToMany) {
            OneToMany oneToManyValue = (OneToMany) collectionValue.getElement();
            referencedClass = oneToManyValue.getAssociatedClass();
        } else if (collectionValue.getElement() instanceof ManyToOne) {
            // Case for bi-directional relation with @JoinTable on the owning @ManyToOne side.
            ManyToOne manyToOneValue = (ManyToOne) collectionValue.getElement();
            referencedClass = manyToOneValue.getMappings().getClass(manyToOneValue.getReferencedEntityName());
        }

        // If there's an @AuditMappedBy specified, returning it directly.
        String auditMappedBy = propertyAuditingData.getAuditMappedBy();
        if (auditMappedBy != null) {
View Full Code Here

      collValue.setCollectionTable( associationTableBinder.bind() );
    }
    bindFilters( isCollectionOfEntities );
    bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings );

    ManyToOne element = null;
    if ( isCollectionOfEntities ) {
      element =
          new ManyToOne( mappings,  collValue.getCollectionTable() );
      collValue.setElement( element );
      element.setReferencedEntityName( collType.getName() );
      //element.setFetchMode( fetchMode );
      //element.setLazy( fetchMode != FetchMode.JOIN );
      //make the second join non lazy
      element.setFetchMode( FetchMode.JOIN );
      element.setLazy( false );
      element.setIgnoreNotFound( ignoreNotFound );
      // as per 11.1.38 of JPA-2 spec, default to primary key if no column is specified by @OrderBy.
      if ( hqlOrderBy != null ) {
        collValue.setManyToManyOrdering(
            buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
        );
      }
      ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
      String fkName = fk != null ? fk.inverseName() : "";
      if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) element.setForeignKeyName( fkName );
    }
    else if ( anyAnn != null ) {
      //@ManyToAny
      //Make sure that collTyp is never used during the @ManyToAny branch: it will be set to void.class
      PropertyData inferredData = new PropertyInferredData(null, property, "unsupported", mappings.getReflectionManager() );
View Full Code Here

      collValue.setCollectionTable( associationTableBinder.bind() );
    }
    bindFilters( isCollectionOfEntities );
    bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings );

    ManyToOne element = null;
    if ( isCollectionOfEntities ) {
      element =
          new ManyToOne( mappings,  collValue.getCollectionTable() );
      collValue.setElement( element );
      element.setReferencedEntityName( collType.getName() );
      //element.setFetchMode( fetchMode );
      //element.setLazy( fetchMode != FetchMode.JOIN );
      //make the second join non lazy
      element.setFetchMode( FetchMode.JOIN );
      element.setLazy( false );
      element.setIgnoreNotFound( ignoreNotFound );
      // as per 11.1.38 of JPA-2 spec, default to primary key if no column is specified by @OrderBy.
      if ( hqlOrderBy != null ) {
        collValue.setManyToManyOrdering(
            buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
        );
      }
      ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
      String fkName = fk != null ? fk.inverseName() : "";
      if ( !BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkName );
    }
    else if ( anyAnn != null ) {
      //@ManyToAny
      //Make sure that collTyp is never used during the @ManyToAny branch: it will be set to void.class
      PropertyData inferredData = new PropertyInferredData(null, property, "unsupported", mappings.getReflectionManager() );
View Full Code Here

        if ( otherSideJoin != null ) {
          //@OneToOne @JoinTable
          Join mappedByJoin = buildJoinFromMappedBySide(
              (PersistentClass) persistentClasses.get( ownerEntity ), otherSideProperty, otherSideJoin
          );
          ManyToOne manyToOne = new ManyToOne( mappings, mappedByJoin.getTable() );
          //FIXME use ignore not found here
          manyToOne.setIgnoreNotFound( ignoreNotFound );
          manyToOne.setCascadeDeleteEnabled( value.isCascadeDeleteEnabled() );
          manyToOne.setEmbedded( value.isEmbedded() );
          manyToOne.setFetchMode( value.getFetchMode() );
          manyToOne.setLazy( value.isLazy() );
          manyToOne.setReferencedEntityName( value.getReferencedEntityName() );
          manyToOne.setUnwrapProxy( value.isUnwrapProxy() );
          prop.setValue( manyToOne );
          Iterator otherSideJoinKeyColumns = otherSideJoin.getKey().getColumnIterator();
          while ( otherSideJoinKeyColumns.hasNext() ) {
            Column column = (Column) otherSideJoinKeyColumns.next();
            Column copy = new Column();
            copy.setLength( column.getLength() );
            copy.setScale( column.getScale() );
            copy.setValue( manyToOne );
            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() );
            manyToOne.addColumn( copy );
          }
          mappedByJoin.addProperty( prop );
        }
        else {
          propertyHolder.addProperty( prop, inferredData.getDeclaringClass() );
View Full Code Here

      else {
        mapKeyType = property.getMapKey().getName();
      }
      PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( mapKeyType );
      boolean isIndexOfEntities = collectionEntity != null;
      ManyToOne element = null;
      org.hibernate.mapping.Map mapValue = (org.hibernate.mapping.Map) this.collection;
      if ( isIndexOfEntities ) {
        element = new ManyToOne( mappings, mapValue.getCollectionTable() );
        mapValue.setIndex( element );
        element.setReferencedEntityName( mapKeyType );
        //element.setFetchMode( fetchMode );
        //element.setLazy( fetchMode != FetchMode.JOIN );
        //make the second join non lazy
        element.setFetchMode( FetchMode.JOIN );
        element.setLazy( false );
        //does not make sense for a map key element.setIgnoreNotFound( ignoreNotFound );
      }
      else {
        XClass elementClass;
        AnnotatedClassType classType;
View Full Code Here

    }
    else if ( value instanceof SimpleValue ) {
      SimpleValue sourceValue = (SimpleValue) value;
      SimpleValue targetValue;
      if ( value instanceof ManyToOne ) {
        ManyToOne sourceManyToOne = (ManyToOne) sourceValue;
        ManyToOne targetManyToOne = new ManyToOne( mappings, collection.getCollectionTable() );
        targetManyToOne.setFetchMode( FetchMode.DEFAULT );
        targetManyToOne.setLazy( true );
        //targetValue.setIgnoreNotFound( ); does not make sense for a map key
        targetManyToOne.setReferencedEntityName( sourceManyToOne.getReferencedEntityName() );
        targetValue = targetManyToOne;
      }
      else {
        targetValue = new SimpleValue( mappings, collection.getCollectionTable() );
        targetValue.setTypeName( sourceValue.getTypeName() );
View Full Code Here

      String name = subnode.getName();
      String propertyName = subnode.attributeValue( "name" );

      Value value = null;
      if ( "many-to-one".equals( name ) ) {
        value = new ManyToOne( mappings, table );
        bindManyToOne( subnode, (ManyToOne) value, propertyName, true, mappings );
      }
      else if ( "any".equals( name ) ) {
        value = new Any( mappings, table );
        bindAny( subnode, (Any) value, true, mappings );
View Full Code Here

          );
        mappings.addCollection( collection );
        value = collection;
      }
      else if ( "many-to-one".equals( name ) || "key-many-to-one".equals( name ) ) {
        value = new ManyToOne( mappings, component.getTable() );
        String relativePath;
        if (isEmbedded) {
          relativePath = propertyName;
        }
        else {
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.ManyToOne

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.