Spring Roo
  1. Spring Roo
  2. ROO-623

Change entities' findBlah(id) method to accept null ids

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.1.RELEASE
    • Fix Version/s: 1.0.2.RELEASE
    • Component/s: PERSISTENCE
    • Labels:
      None

      Description

      This improvement would have two benefits:

      • help to work around ROO-581, by removing the need to register null-friendly PropertyEditors for multiple entity classes in multiple controllers
      • conform more closely to Postel's Law: "be conservative in what you do, be liberal in what you accept from others"

      At the moment, Roo generates this finder in Pizza_Roo_Entity.aj:

      public static Pizza Pizza.findPizza(Long id) {    
          if (id == null) throw new IllegalArgumentException("An identifier is required to retrieve an instance of Pizza");        
          return entityManager().find(Pizza.class, id);        
      }

      This code would be more usable if it gracefully accepted a null id, as follows:

      public static Pizza Pizza.findPizza(Long id) {    
          if (id == null) return null;        
          return entityManager().find(Pizza.class, id);        
      }

        Activity

        Hide
        Ben Alex added a comment -

        Added to SVN rev 625.

        Show
        Ben Alex added a comment - Added to SVN rev 625.

          People

          • Assignee:
            Ben Alex
            Reporter:
            Andrew Swan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: