I've got this object:
@Getter
@Setter
public class PhaseBean {
private Long id;
private String name;
private PhaseBean subPhase;
}
that is passed as input to this repo method (simplified):
@Query(value=
" ...
and ( :#{#phaseBean.id} is null or :#{#phaseBean.name} is null .... //row1
and ( :#{#phaseBean.subPhase} is null or :#{#phaseBean.subPhase.id} is null or ... //row2
... "
)
List<Phase> load(@Param("phaseBean") PhaseBean phaseBean);
In the test that I've done, the phaseBean is valorized in this way:
id = 3
name = null
subPhase = null
and when the repo method is executed, I get this error:
SpelEvaluationException: EL1007E: Property or field 'id' cannot be found on null
I did 2 different tests:
- comment "row1" of the query and execute the method -> same error
- comment "row2" of the query and execute the method -> method works!
So I'm sure that the problem is that the check :#{#phaseBean.subPhase} is null is not working for the inner object.
Any suggestion? Thanks a lot.