This method does the following : it gets the int startAge from the Database. This parameter has a set default of 0 and is not nullable. Then it checks if it´s bigger than zero, in which case it adds it to dob and returns it.
Pretty simple, actually, but i keep getting a NullPointerException on the marked line, although the Database makes sure the variable CANNOT be null and the parameter groupFrom in the entity class is also set to nullable=false.
Any hints ?
public static DateMidnight getRealStartDate(DateMidnight startDate, DateMidnight dob, Groups group){
DateMidnight realStart = null;
int startAge = group.getGroupFrom(); //nullPointerException
if (startAge > 0) {
realStart = dob.plusMonths(startAge);
} else {
realStart = startDate;
}
return realStart;
}
If you get a NullPointerException at that line it means that the variable group is null.