If entity.getHistory() is null following code snippet:
(getEntityManager() returns spring injected EntityManager, database field history type is: text or varchar2(20
The JDBC setNull with sql type parameter is fallback for legacy JDBC drivers that do not pass the JDBC Driver Test Suite.
One can guard against null errors within the query as follows:
SELECT a FROM Author a WHERE :lastName IS NULL OR LOWER(a.lastName) = :lastName
This should work in Postgresql after the fix of this issue.
Most of above answers are meaningful and helped me to narrow down issue.
I fixed issue for nulls like this:
setParameter(8, getDate(), TemporalType.DATE);
There's a simple fix: when you're building the query string, if a parameter is going to be null -- use "null" instead of "?".
As @araqnid says, Hibernate is incorrectly casting null values into type bytea because it doesn't know any better.