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

Integer entity field generates NPE in getSearchPredicates

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.4.0.Final
    • 1.3.3.Final
    • Scaffold
    • 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)
         ...
      }
      

      Attachments

        Activity

          People

            rhn-support-ggastald George Gastaldi
            agoncal Antonio Goncalves (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: