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

Finders - Non required fields are enforced via exception in the code but not in the jsp.

    XMLWordPrintable

    Details

      Description

      If I create a finder for a Person object

      finder add findPersonByFirstNameAndLastName

      where only first name is required:

      @NotNull
      private String firstName;

      private String lastName;

      The generated view only enforces firstName, but if you leave last name empty an exception occurs.

      This exception is because the generated .aj file still requires the lastName field.

      public static TypedQuery<Person> Person.findPersonsByFirstNameAndLastName(String firstName, String lastName)

      { if (firstName == null || firstName.length() == 0) throw new IllegalArgumentException("The firstName argument is required"); if (lastName == null || lastName.length() == 0) throw new IllegalArgumentException("The lastName argument is required"); EntityManager em = Celebrity.entityManager(); TypedQuery<Person> q = em.createQuery("SELECT Person FROM Person AS person WHERE person.firstName = :firstName AND person.lastName = :lastName", Person.class); q.setParameter("firstName", firstName); q.setParameter("lastName", lastName); return q; }

        Attachments

          Activity

            People

            Assignee:
            sschmidt Stefan Schmidt
            Reporter:
            sdmurphy Scott Murphy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: