Package javax.persistence

Examples of javax.persistence.OneToMany


        //System.out.println("class "+relationship.getFromBeanName());
       
        if (!returnType.getActualTypeArguments()[0].toString().equals("class "+relationship.getToBeanClassName()))
          throw new EntityCheckNoCollectionTypeException(beanName, relationship.getName());
       
        OneToMany annotation = (OneToMany)method.getAnnotation(OneToMany.class);
        Class targetEntity = annotation.targetEntity();

        if (targetEntity.getName().equals("void"))
          throw new MissingTargetEntityException(beanName, relationship.getName());
           

        CascadeType cascades[] = annotation.cascade();
       
        for(CascadeType cascade:cascades)
        {
          // Rimossa perche' ci sono casi in cui e' necessario avere il MERGE !!!
//            if (cascade.equals(CascadeType.MERGE) || cascade.equals(CascadeType.ALL))
//              throw new EntityCheckWrongMergeException(beanName, relationship.getName());
        }
       
        if (annotation.mappedBy().equals(""))
          throw new EntityCheckMissingMappedByException(beanName, relationship.getName());
       
       
        Field targetFields[] = targetEntity.getDeclaredFields();
       
        if(!contains(targetFields,annotation.mappedBy()))
          throw new EntityCheckWrongMappedByTypeException(beanName, relationship.getName());
       
        if(!type(targetFields,annotation.mappedBy()))         
          throw new EntityCheckWrongMappedByFieldException(beanName, relationship.getName(), annotation.mappedBy(), targetEntity.getSimpleName());

        return true;
    }
View Full Code Here


      for (int k = 0; k < annotations.length; k++)
      {
        if (annotations[k].annotationType().equals(javax.persistence.OneToMany.class))
        {
          OneToMany a = (OneToMany) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(false);
          rel.setToMany(true);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());

        }

        if (annotations[k].annotationType().equals(javax.persistence.ManyToOne.class))
        {
          ManyToOne a = (ManyToOne) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(true);
          rel.setToMany(false);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
        }

        if (annotations[k].annotationType().equals(javax.persistence.ManyToMany.class))
        {
          ManyToMany a = (ManyToMany) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(true);
          rel.setToMany(true);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());
        }

        if (annotations[k].annotationType().equals(javax.persistence.OneToOne.class))
        {
          OneToOne a = (OneToOne) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(false);
          rel.setToMany(false);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());
        }

        /**
         * Annotazioni relative alla generazione !!!!
         *
 
View Full Code Here

      for (int k = 0; k < annotations.length; k++)
      {
        if (annotations[k].annotationType().equals(javax.persistence.OneToMany.class))
        {
          OneToMany a = (OneToMany) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setUsed(true);

          rel.setName(methods[j].getName());

          rel.setFromMany(false);
          rel.setToMany(true);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());
        }

        if (annotations[k].annotationType().equals(javax.persistence.ManyToOne.class))
        {
          ManyToOne a = (ManyToOne) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(true);
          rel.setToMany(false);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
        }

        if (annotations[k].annotationType().equals(javax.persistence.ManyToMany.class))
        {
          ManyToMany a = (ManyToMany) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(true);
          rel.setToMany(true);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());
        }

        if (annotations[k].annotationType().equals(javax.persistence.OneToOne.class))
        {
          OneToOne a = (OneToOne) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(false);
          rel.setToMany(false);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());
        }
      }

      if (rel != null)
        tmp.add(rel);
View Full Code Here

      for (int k = 0; k < annotations.length; k++)
      {
        if (annotations[k].annotationType().equals(javax.persistence.OneToMany.class))
        {
          OneToMany a = (OneToMany) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(false);
          rel.setToMany(true);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());

          // tmp.add(rel);
        }

        if (annotations[k].annotationType().equals(javax.persistence.ManyToOne.class))
        {
          ManyToOne a = (ManyToOne) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(true);
          rel.setToMany(false);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());

          // tmp.add(rel);
        }

        if (annotations[k].annotationType().equals(javax.persistence.ManyToMany.class))
        {
          ManyToMany a = (ManyToMany) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(true);
          rel.setToMany(true);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());

          // tmp.add(rel);
        }

        if (annotations[k].annotationType().equals(javax.persistence.OneToOne.class))
        {
          OneToOne a = (OneToOne) annotations[k];

          if (a.targetEntity().equals(""))
            throw new MissingTargetEntityException(beanName, methods[j].getName());

          rel = new Relationship(beanName);
          rel.setName(methods[j].getName());

          rel.setFromMany(false);
          rel.setToMany(false);
          rel.setToBeanClassName(a.targetEntity().getCanonicalName());
          rel.setMappedBy(a.mappedBy());

          // tmp.add(rel);
        }

        /**
 
View Full Code Here

     * @param objectVertex
     */
    private <DataType> void loadMap(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classLoader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
        boolean eagerLoad = false;
        // property may be associated to a onetomany or manytomany mapping. in such a case, check if there is an eager loading info
        OneToMany oneToMany = p.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            eagerLoad = FetchType.EAGER.equals(oneToMany.fetch());
        }
        if (!eagerLoad) {
            ManyToMany manyToMany = p.getAnnotation(ManyToMany.class);
            if (manyToMany != null) {
                eagerLoad = FetchType.EAGER.equals(manyToMany.fetch());
View Full Code Here

     * @param objectVertex
     */
    private <DataType> void loadCollection(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classLoader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
        boolean eagerLoad = false;
        // property may be associated to a onetomany or manytomany mapping. in such a case, check if there is an eager loading info
        OneToMany oneToMany = p.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            eagerLoad = FetchType.EAGER.equals(oneToMany.fetch());
        }
        if (!eagerLoad) {
            ManyToMany manyToMany = p.getAnnotation(ManyToMany.class);
            if (manyToMany != null) {
                eagerLoad = FetchType.EAGER.equals(manyToMany.fetch());
View Full Code Here

     * @param objectVertex
     */
    private <DataType> void loadMap(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classLoader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
        boolean eagerLoad = false;
        // property may be associated to a onetomany or manytomany mapping. in such a case, check if there is an eager loading info
        OneToMany oneToMany = p.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            eagerLoad = FetchType.EAGER.equals(oneToMany.fetch());
        }
        if (!eagerLoad) {
            ManyToMany manyToMany = p.getAnnotation(ManyToMany.class);
            if (manyToMany != null) {
                eagerLoad = FetchType.EAGER.equals(manyToMany.fetch());
View Full Code Here

     * @param objectVertex
     */
    private <DataType> void loadCollection(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classLoader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
        boolean eagerLoad = false;
        // property may be associated to a onetomany or manytomany mapping. in such a case, check if there is an eager loading info
        OneToMany oneToMany = p.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            eagerLoad = FetchType.EAGER.equals(oneToMany.fetch());
        }
        if (!eagerLoad) {
            ManyToMany manyToMany = p.getAnnotation(ManyToMany.class);
            if (manyToMany != null) {
                eagerLoad = FetchType.EAGER.equals(manyToMany.fetch());
View Full Code Here

     * @param objectVertex
     */
    private <DataType> void loadMap(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classLoader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
        boolean eagerLoad = false;
        // property may be associated to a onetomany or manytomany mapping. in such a case, check if there is an eager loading info
        OneToMany oneToMany = p.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            eagerLoad = FetchType.EAGER.equals(oneToMany.fetch());
        }
        if (!eagerLoad) {
            ManyToMany manyToMany = p.getAnnotation(ManyToMany.class);
            if (manyToMany != null) {
                eagerLoad = FetchType.EAGER.equals(manyToMany.fetch());
View Full Code Here

     * @param objectVertex
     */
    private <DataType> void loadCollection(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classLoader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
        boolean eagerLoad = false;
        // property may be associated to a onetomany or manytomany mapping. in such a case, check if there is an eager loading info
        OneToMany oneToMany = p.getAnnotation(OneToMany.class);
        if (oneToMany != null) {
            eagerLoad = FetchType.EAGER.equals(oneToMany.fetch());
        }
        if (!eagerLoad) {
            ManyToMany manyToMany = p.getAnnotation(ManyToMany.class);
            if (manyToMany != null) {
                eagerLoad = FetchType.EAGER.equals(manyToMany.fetch());
View Full Code Here

TOP

Related Classes of javax.persistence.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.