Examples of ManyToOne


Examples of net.sourceforge.jpaxjc.ns.persistence.orm.ManyToOne

            }

            if ( f.getPropertyInfo().getCustomizations().find( ORM_NS, "many-to-one" ) != null )
            {
                final CPluginCustomization pc = f.getPropertyInfo().getCustomizations().find( ORM_NS, "many-to-one" );
                final ManyToOne m = JAXB.unmarshal( new DOMSource( pc.element ), ManyToOne.class );

                if ( m.getName() == null )
                {
                    m.setName( f.getPropertyInfo().getName( false ) );
                }

                attributes.getManyToOne().add( m );
                mapped = true;

                if ( !pc.isAcknowledged() )
                {
                    pc.markAsAcknowledged();
                }
            }

            if ( f.getPropertyInfo().getCustomizations().find( ORM_NS, "one-to-many" ) != null )
            {
                final CPluginCustomization pc = f.getPropertyInfo().getCustomizations().find( ORM_NS, "one-to-many" );
                final OneToMany o = JAXB.unmarshal( new DOMSource( pc.element ), OneToMany.class );

                if ( o.getName() == null )
                {
                    o.setName( f.getPropertyInfo().getName( false ) );
                }

                attributes.getOneToMany().add( o );

                this.generateCollectionSetter( f.parent().parent().getCodeModel(), f.parent(), f.getPropertyInfo() );
                mapped = true;

                if ( !pc.isAcknowledged() )
                {
                    pc.markAsAcknowledged();
                }
            }

            if ( f.getPropertyInfo().getCustomizations().find( ORM_NS, "one-to-one" ) != null )
            {
                final CPluginCustomization pc = f.getPropertyInfo().getCustomizations().find( ORM_NS, "one-to-one" );
                final OneToOne o = JAXB.unmarshal( new DOMSource( pc.element ), OneToOne.class );

                if ( o.getName() == null )
                {
                    o.setName( f.getPropertyInfo().getName( false ) );
                }

                attributes.getOneToOne().add( o );
                mapped = true;

                if ( !pc.isAcknowledged() )
                {
                    pc.markAsAcknowledged();
                }
            }

            if ( f.getPropertyInfo().getCustomizations().find( ORM_NS, "many-to-many" ) != null )
            {
                final CPluginCustomization pc = f.getPropertyInfo().getCustomizations().find( ORM_NS, "many-to-many" );
                final ManyToMany m = JAXB.unmarshal( new DOMSource( pc.element ), ManyToMany.class );

                if ( m.getName() == null )
                {
                    m.setName( f.getPropertyInfo().getName( false ) );
                }

                attributes.getManyToMany().add( m );

                this.generateCollectionSetter( f.parent().parent().getCodeModel(), f.parent(), f.getPropertyInfo() );
View Full Code Here

Examples of org.apache.openejb.jee.jpa.ManyToOne

                    leftOneToMany.setMappedBy(rightFieldName);
                    setCascade(rightRole, leftOneToMany);
                    leftEntity.getAttributes().getOneToMany().add(leftOneToMany);

                    // right
                    ManyToOne rightManyToOne = null;
                    rightManyToOne = new ManyToOne();
                    rightManyToOne.setName(rightFieldName);
                    rightManyToOne.setSyntheticField(rightSynthetic);
                    setCascade(leftRole, rightManyToOne);
                    rightEntity.getAttributes().getManyToOne().add(rightManyToOne);

                    // link
                    leftOneToMany.setRelatedField(rightManyToOne);
                    rightManyToOne.setRelatedField(leftOneToMany);
                } else if (!leftIsOne && rightIsOne) {
                    //
                    // many-to-one
                    //

                    // left
                    ManyToOne leftManyToOne = null;
                    leftManyToOne = new ManyToOne();
                    leftManyToOne.setName(leftFieldName);
                    leftManyToOne.setSyntheticField(leftSynthetic);
                    setCascade(rightRole, leftManyToOne);
                    leftEntity.getAttributes().getManyToOne().add(leftManyToOne);

                    // right
                    OneToMany rightOneToMany = null;
                    rightOneToMany = new OneToMany();
                    rightOneToMany.setName(rightFieldName);
                    rightOneToMany.setSyntheticField(rightSynthetic);
                    rightOneToMany.setMappedBy(leftFieldName);
                    setCascade(leftRole, rightOneToMany);
                    rightEntity.getAttributes().getOneToMany().add(rightOneToMany);

                    // link
                    leftManyToOne.setRelatedField(rightOneToMany);
                    rightOneToMany.setRelatedField(leftManyToOne);
                } else if (!leftIsOne && !rightIsOne) {
                    //
                    // many-to-many
                    //
View Full Code Here

Examples of org.chromattic.api.annotations.ManyToOne

        ValueInfo vi = svpi.getValue();
        if (vi instanceof BeanValueInfo) {
          BeanValueInfo bvi = (BeanValueInfo)vi;

          //
          ManyToOne manyToOneAnn = propertyInfo.getAnnotation(ManyToOne.class);
          RelationshipType type = manyToOneAnn.type();

          //
          if (type == RelationshipType.HIERARCHIC) {
            RelationshipMapping hierarchyMapping = new ManyToOneMapping(bvi.getTypeInfo(), RelationshipType.HIERARCHIC);
            PropertyMapping<RelationshipMapping> manyToOneMapping = new PropertyMapping<RelationshipMapping>(propertyInfo, hierarchyMapping);
View Full Code Here

Examples of org.hibernate.mapping.ManyToOne

     * @param processedColumns
     * @param rc
     * @param propName
     */
    private Property bindManyToOne(String propertyName, boolean mutable, Table table, ForeignKey fk, Set processedColumns) {
        ManyToOne value = new ManyToOne(table);
        value.setReferencedEntityName( fk.getReferencedEntityName() );
    Iterator columns = fk.getColumnIterator();
        while ( columns.hasNext() ) {
      Column fkcolumn = (Column) columns.next();
            checkColumn(fkcolumn);
            value.addColumn(fkcolumn);
            processedColumns.add(fkcolumn);
    }
        value.setFetchMode(FetchMode.SELECT);

        return makeEntityProperty(propertyName, mutable, table, fk, value, false);
     }
View Full Code Here

Examples of org.hibernate.mapping.ManyToOne



        if(manyToMany) {

          ManyToOne element = new ManyToOne( collection.getCollectionTable() );
          //TODO: find the other foreignkey and choose the other side.
          Iterator foreignKeyIterator = foreignKey.getTable().getForeignKeyIterator();
          List keys = new ArrayList();
          while ( foreignKeyIterator.hasNext() ) {
        Object next = foreignKeyIterator.next();
        if(next!=foreignKey) {
          keys.add(next);
        }
      }

          if(keys.size()>1) {
            throw new JDBCBinderException("more than one other foreign key to choose from!"); // todo: handle better ?
          }

          ForeignKey fk = (ForeignKey) keys.get( 0 );

          String tableToClassName = bindCollection( rc, foreignKey, fk, collection );

      element.setReferencedEntityName( tableToClassName );
      element.addColumn( fk.getColumn( 0 ) );
      collection.setElement( element );

        } else {
          String tableToClassName = bindCollection( rc, foreignKey, null, collection );
View Full Code Here

Examples of org.hibernate.mapping.ManyToOne

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

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

Examples of org.hibernate.mapping.ManyToOne

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

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

Examples of org.hibernate.mapping.ManyToOne

        }
        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

Examples of org.hibernate.mapping.ManyToOne

            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
TOP
Copyright © 2018 www.massapi.com. 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.