Supplying null parameter to the following query results in PSQLException: ERROR: operator does not exist: bytea = integer
Query query = em.createQuery("select m from MyEntity m where (?1 is null or ?1=m.something)");
query.setParameter(1, null);
query.getResultList();
It works with H2 tests, but fails in production with Postgres. Using named parameter also fixes the problem:
Query correct = em.createQuery("select m from MyEntity m where (:e is null or :e=m.something)");
correct.setParameter("e", null);
correct.getResultList();
I could not create a test case because this seems like a Postgres specific bug |