Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1066

Integer entity field generates NPE in getSearchPredicates

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.3.3.Final
    • Fix Version/s: 1.4.0.Final
    • Component/s: Scaffold
    • Labels:
      None

      Description

      When I add an Integer attribute to an entity with the following command :

      entity --named Book ;
      field number --type java.lang.Integer --named nbOfPage ;
      

      It creates the following

      @Entity
      public class Book implements Serializable
      {
       
         @Id
         @GeneratedValue(strategy = GenerationType.AUTO)
         @Column(name = "id", updatable = false, nullable = false)
         private Long id = null;
         @Version
         @Column(name = "version")
         private int version = 0;
       
         @Column
         private Integer nbOfPage;
         ...
      }
      

      The generated Faces BookBean handles it as a datatype instead of an object, so it gets an NPE if the attribute is null. The generated code is :

       
         private Predicate[] getSearchPredicates(Root<Book> root)
         {
         ...
         Integer nbOfPage = this.example.getNbOfPage();
         if (nbOfPage != 0)
         ...
      }
      

      But it should check null value :

       
         private Predicate[] getSearchPredicates(Root<Book> root)
         {
         ...
         Integer nbOfPage = this.example.getNbOfPage();
         if (nbOfPage != null && nbOfPage != 0)
         ...
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                gastaldi George Gastaldi
                Reporter:
                agoncal Antonio Goncalves
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: