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

Allow nullable finder parameters for nullable fields

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.1.1.RELEASE
    • Fix Version/s: None
    • Component/s: DYNAMIC FINDERS
    • Labels:
      None

      Description

      A typical dynamic finder starts by checking if all input variables are NULL, and then throwing an exception if they are. However, null can be a perfectly valid argument. Consider the following

      CREATE TABLE Node (
      id int not null auto_increment,
      parentId int,
      name varchar(50),
      primary key(id),
      foreign key parentId refrences Node(id)
      );

      Here you can have many trees:
      (1,NULL,'A'), (2,1,'A1'), (3,1,'A2'), (4,2,'A1.1'),
      (5,NULL,'B'), (6,5,'B1'), (7,5,'B2')

      Now if I want to make a finder which finds a collection of nodes on a level, and I want to use it to find all the roots, findNodesByParentId(null) is a perfectly valid call, just as valid as doing findNodesByParentId(Node.read(1))

      I suggest therefore that the dynamic finder creation checks if NULL is a valid argument for the entity before adding the constraint on the method that it must have a value

      Cheers

      Nik

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              niklassaers Niklas Saers
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: