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