Package org.hibernate.mapping

Examples of org.hibernate.mapping.OneToMany


  public static void bindCollectionSecondPass(Element node, Collection collection,
      java.util.Map persistentClasses, Mappings mappings, java.util.Map inheritedMetas)
      throws MappingException {

    if ( collection.isOneToMany() ) {
      OneToMany oneToMany = (OneToMany) collection.getElement();
      String assocClass = oneToMany.getReferencedEntityName();
      PersistentClass persistentClass = (PersistentClass) persistentClasses.get( assocClass );
      if ( persistentClass == null ) {
        throw new MappingException( "Association references unmapped class: " + assocClass );
      }
      oneToMany.setAssociatedClass( persistentClass );
      collection.setCollectionTable( persistentClass.getTable() );

      if ( LOG.isDebugEnabled() ) {
        LOG.debugf( "Mapping collection: %s -> %s", collection.getRole(), collection.getCollectionTable().getName() );
      }
View Full Code Here


    }

    private String getMappedBy(Collection collectionValue) {
        PersistentClass referencedClass = null;
        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());
        }
View Full Code Here

    }

    private String getMappedBy(Collection collectionValue) {
        PersistentClass referencedClass = null;
        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());
        }
View Full Code Here

      collection.setExtraLazy(true);
    }

    Element oneToManyNode = node.element( "one-to-many" );
    if ( oneToManyNode != null ) {
      OneToMany oneToMany = new OneToMany( mappings, collection.getOwner() );
      collection.setElement( oneToMany );
      bindOneToMany( oneToManyNode, oneToMany, mappings );
      // we have to set up the table later!! yuck
    }
    else {
View Full Code Here

  public static void bindCollectionSecondPass(Element node, Collection collection,
      java.util.Map persistentClasses, Mappings mappings, java.util.Map inheritedMetas)
      throws MappingException {

    if ( collection.isOneToMany() ) {
      OneToMany oneToMany = (OneToMany) collection.getElement();
      String assocClass = oneToMany.getReferencedEntityName();
      PersistentClass persistentClass = (PersistentClass) persistentClasses.get( assocClass );
      if ( persistentClass == null ) {
        throw new MappingException( "Association references unmapped class: " + assocClass );
      }
      oneToMany.setAssociatedClass( persistentClass );
      collection.setCollectionTable( persistentClass.getTable() );

      log.info(
          "Mapping collection: " + collection.getRole() +
          " -> " + collection.getCollectionTable().getName()
View Full Code Here

      collection.setExtraLazy(true);
    }

    Element oneToManyNode = node.element( "one-to-many" );
    if ( oneToManyNode != null ) {
      OneToMany oneToMany = new OneToMany( mappings, collection.getOwner() );
      collection.setElement( oneToMany );
      bindOneToMany( oneToManyNode, oneToMany, mappings );
      // we have to set up the table later!! yuck
    }
    else {
View Full Code Here

  public static void bindCollectionSecondPass(Element node, Collection collection,
      java.util.Map persistentClasses, Mappings mappings, java.util.Map inheritedMetas)
      throws MappingException {

    if ( collection.isOneToMany() ) {
      OneToMany oneToMany = (OneToMany) collection.getElement();
      String assocClass = oneToMany.getReferencedEntityName();
      PersistentClass persistentClass = (PersistentClass) persistentClasses.get( assocClass );
      if ( persistentClass == null ) {
        throw new MappingException( "Association references unmapped class: " + assocClass );
      }
      oneToMany.setAssociatedClass( persistentClass );
      collection.setCollectionTable( persistentClass.getTable() );

      log.info(
          "Mapping collection: " + collection.getRole() +
          " -> " + collection.getCollectionTable().getName()
View Full Code Here

    new DependantValue(null,null).accept(vv);
    new IdentifierBag(null).accept(vv);
    new List(null).accept(vv);
    new ManyToOne(null).accept(vv);
    new Map(null).accept(vv);
    new OneToMany(null).accept(vv);
    new OneToOne(null, new RootClass() ).accept(vv);
    new PrimitiveArray(null).accept(vv);
    new Set(null).accept(vv);
    new SimpleValue().accept(vv);
 
View Full Code Here

  }

  private String getMappedBy(Collection collectionValue) {
    PersistentClass referencedClass = null;
    if ( collectionValue.getElement() instanceof OneToMany ) {
      final 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.
      final ManyToOne manyToOneValue = (ManyToOne) collectionValue.getElement();
      referencedClass = manyToOneValue.getMappings().getClass( manyToOneValue.getReferencedEntityName() );
View Full Code Here

      collection.setExtraLazy(true);
    }

    Element oneToManyNode = node.element( "one-to-many" );
    if ( oneToManyNode != null ) {
      OneToMany oneToMany = new OneToMany( mappings, collection.getOwner() );
      collection.setElement( oneToMany );
      bindOneToMany( oneToManyNode, oneToMany, mappings );
      // we have to set up the table later!! yuck
    }
    else {
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.OneToMany

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.