Examples of OneToMany


Examples of org.hibernate.mapping.OneToMany

      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

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

Examples of org.hibernate.mapping.OneToMany

  }

    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

Examples of org.hibernate.mapping.OneToMany

      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

Examples of se.unlogic.standardutils.dao.annotations.OneToMany

          // TODO check auto fields
          throw new RuntimeException("OneToOne relations are not implemented yet!");

        } else if (field.isAnnotationPresent(OneToMany.class)) {

          OneToMany oneToMany = field.getAnnotation(OneToMany.class);

          this.checkOrderByAnnotation(field, orderBy);

          if (field.getType() != List.class) {

            throw new UnsupportedFieldTypeException("The annotated field " + field.getName() + " in  " + beanClass + " is of unsupported type "
                + field.getType() + ". Fields annotated as @OneToMany have to be a genericly typed " + List.class, field, OneToMany.class,
                beanClass);
          }

          if (ReflectionUtils.getGenericlyTypeCount(field) != 1) {

            throw new UnsupportedFieldTypeException("The annotated field " + field.getName() + " in  " + beanClass
                + " is genericly typed. Fields annotated as @OneToMany have to be a genericly typed " + List.class, field, OneToMany.class,
                beanClass);
          }

          // This is a bit ugly but still necessary until someone else
          // comes up with something smarter...
          Class<?> remoteClass = (Class<?>) ReflectionUtils.getGenericType(field);

          SimplifiedRelation simplifiedRelation = field.getAnnotation(SimplifiedRelation.class);

          if (simplifiedRelation != null) {

            this.oneToManyRelations.put(field, SimplifiedOneToManyRelation.getGenericInstance(beanClass, remoteClass, field, this, typePopulators, queryParameterPopulators));

          } else {

            // Use this class pks, no extra field
            this.oneToManyRelations.put(field, DefaultOneToManyRelation.getGenericInstance(beanClass, remoteClass, field, daoFactory, daoManaged));
          }

          if (oneToMany.autoAdd()) {
            this.autoAddRelations.add(field);
          }

          if (oneToMany.autoUpdate()) {
            this.autoUpdateRelations.add(field);
          }

          if (oneToMany.autoGet()) {
            this.autoGetRelations.add(field);
          }

        } else if (field.isAnnotationPresent(ManyToOne.class)) {
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.