EL1007E: Property or field cannot be found on null SPEL

105 Views Asked by At

I'm trying to run a query:

@Query(value = "SELECT o from ORG o join o.biz bizid "
          + "WHERE ( (:#{#x.id} IS NULL) OR bizid.id) = :#{#x.id} ) "
findBy(SearchObject x);

I get an error:

EL1007E: Property or field 'id' cannot be found on null

I thought the IS NULL check would work so that it only goes to the OR part if it is not null? What am I missing here?

I did check from the logs that x.id is actually null.

I did a same query like this:

@Query(value = "SELECT o from ORG o join o.biz bizid "
          + "WHERE ( (:id IS NULL) OR bizid.id) = :id ) "
findBy(@Param("id") id);

It works and I get no error from this query, so this seems to have something to do with how Spring Expression Language works.

0

There are 0 best solutions below