Antonio Goncalves created FORGE-1066:
----------------------------------------
Summary: Integer entity field generates NPE in getSearchPredicates
Key: FORGE-1066
URL:
https://issues.jboss.org/browse/FORGE-1066
Project: Forge
Issue Type: Bug
Components: Scaffold
Affects Versions: 1.3.3.Final
Reporter: Antonio Goncalves
When I add an Integer attribute to an entity with the following command :
{code}
entity --named Book ;
field number --type java.lang.Integer --named nbOfPage ;
{code}
It creates the following
{code}
@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;
...
}
{code}
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 :
{code}
private Predicate[] getSearchPredicates(Root<Book> root)
{
...
Integer nbOfPage = this.example.getNbOfPage();
if (nbOfPage != 0)
...
}
{code}
But it should check null value :
{code}
private Predicate[] getSearchPredicates(Root<Book> root)
{
...
Integer nbOfPage = this.example.getNbOfPage();
if (nbOfPage != null && nbOfPage != 0)
...
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira