Skip to content
Advertisement

Spring repository: HQL using constructor doens’t parse NULL values

I’ve a Spring Repository with this HQL query:

JavaScript

PupillaryDistanceDTO is a POJO annotated with @AllArgsConstructor(Lombok); unfortunately those null values I want to pass to the constructor are creating some troubles:

JavaScript

Removing those null and replacing with some table’s columns, it works. Is there a way to tell Hibernate to interpret those null in the right way?

Advertisement

Answer

You could try to use nullif(1,1) to emulate the null, but it would be better to just create an appropriate constructor that doesn’t require passing nulls.

Advertisement