Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-3545

Dynamic finder generates invalid code

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.5.RELEASE
    • Fix Version/s: None
    • Component/s: DYNAMIC FINDERS
    • Labels:
    • Environment:
      Windows 8.0, STS 3.6.2RELEASE, JDK 1.7.0.25

      Description

      Finder def

      @RooJpaActiveRecord(finders = {"findIndividualJobsByIndividualAndIndividualJobType"})
      

      Model field

      @Enumerated(EnumType.STRING)
      @ElementCollection(targetClass=IndividualJobType.class)
      private List<IndividualJobType> individualJobType;
      

      Generated finder

          public static TypedQuery<IndividualJob> IndividualJob.findIndividualJobsByIndividualAndIndividualJobType(Individual individual, List<IndividualJobType> individualJobType, String sortFieldName, String sortOrder) {
          if (individual == null) throw new IllegalArgumentException("The individual argument is required");
          if (individualJobType == null) throw new IllegalArgumentException("The individualJobType argument is required");
          EntityManager em = IndividualJob.entityManager();
          StringBuilder queryBuilder = new StringBuilder("SELECT o FROM IndividualJob AS o WHERE o.individual = :individual AND");
          for (int i = 0; i < individualJobType.size(); i++) {
              if (i > 0) queryBuilder.append(" AND");
              queryBuilder.append(" :individualJobType_item").append(i).append(" MEMBER OF o.individualJobType");
          }
          if (fieldNames4OrderClauseFilter.contains(sortFieldName)) {
              jpaQuery = jpaQuery + " ORDER BY " + sortFieldName;
              if ("ASC".equalsIgnoreCase(sortOrder) || "DESC".equalsIgnoreCase(sortOrder)) {
                  queryBuilder.append(" " + sortOrder);
              }
          }
          TypedQuery<IndividualJob> q = em.createQuery(queryBuilder.toString(), IndividualJob.class);
          q.setParameter("individual", individual);
          int individualJobTypeIndex = 0;
          for (IndividualJobType _individualjobtype: individualJobType) {
              q.setParameter("individualJobType_item" + individualJobTypeIndex++, _individualjobtype);
          }
          return q;
      }
      

        Attachments

          Activity

            People

            • Assignee:
              eruiz Enrique Ruiz (DiSiD)
              Reporter:
              msummers Mike Summers
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: