Is there a setting to fail when query.setParam(null) is called?

There is a common mistake on the web where we all do namedqueries with c.col=:variable where variable might be null. AND another common mistake is unique constraints with nullable columns.

Since MySQL and SQL standard and postgres return 0 rows with WHERE c.col=null, can we change a setting to fail query.setParameter(null) so this bug doesn’t happen in our software(fail fast). This setting would also fail multi column uninque constraints unless every column was nullable=false. ie. help the users more quickly find this out. Our team found this out quite late since there was no fail-fast in place :(.

Also, postgres has a VERY nice feature where one could turn c.col = :variable into WHERE is not distinct from :variable so that null works and a value works!! ie. one named query instead of some of the nasty queries I see on the web which are ludricous(well, my opinion at least) with case statements and such just trying to do what postgres has.

I am not sure if this is part of SQL standard. it might be. A setting to do that would alleviate a ton of confusion HOWEVER, then there is confusion on uniqueness constraints as well!!!


anyways, just curious if I can help my developers avoid these things in the future by setting some guardrails that are missing in default hibernate.