Package org.hibernate.mapping

Examples of org.hibernate.mapping.ManyToOne


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


        }
        map.setIndex( value );
        map.setIndexNodeName( subnode.attributeValue("node") );
      }
      else if ( "index-many-to-many".equals( name ) || "map-key-many-to-many".equals( name ) ) {
        ManyToOne mto = new ManyToOne( map.getCollectionTable() );
        bindManyToOne(
            subnode,
            mto,
            IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
            map.isOneToMany(),
View Full Code Here

            Collection.DEFAULT_ELEMENT_COLUMN_NAME,
            mappings
          );
      }
      else if ( "many-to-many".equals( name ) ) {
        ManyToOne element = new ManyToOne( collection.getCollectionTable() );
        collection.setElement( element );
        bindManyToOne(
            subnode,
            element,
            Collection.DEFAULT_ELEMENT_COLUMN_NAME,
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

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

        }
        map.setIndex( value );
        map.setIndexNodeName( subnode.attributeValue("node") );
      }
      else if ( "index-many-to-many".equals( name ) || "map-key-many-to-many".equals( name ) ) {
        ManyToOne mto = new ManyToOne( mappings, map.getCollectionTable() );
        bindManyToOne(
            subnode,
            mto,
            IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
            map.isOneToMany(),
View Full Code Here

            Collection.DEFAULT_ELEMENT_COLUMN_NAME,
            mappings
          );
      }
      else if ( "many-to-many".equals( name ) ) {
        ManyToOne element = new ManyToOne( mappings, collection.getCollectionTable() );
        collection.setElement( element );
        bindManyToOne(
            subnode,
            element,
            Collection.DEFAULT_ELEMENT_COLUMN_NAME,
View Full Code Here

    return false;
  }

  public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
    if ( value instanceof ManyToOne ) {
      ManyToOne manyToOne = (ManyToOne) value;
      PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
      if ( ref == null ) {
        throw new AnnotationException(
            "@OneToOne or @ManyToOne on "
                + StringHelper.qualify( entityClassName, path )
                + " references an unknown entity: "
                + manyToOne.getReferencedEntityName()
        );
      }
      BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );
      TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings );
      /*
       * HbmBinder does this only when property-ref != null, but IMO, it makes sense event if it is null
       */
      if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
    }
    else if ( value instanceof OneToOne ) {
      ( (OneToOne) value ).createForeignKey();
    }
    else {
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

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.