| I have dug deep into this before, and a real solution lies only in PostgreSQL, not in Hibernate. There is however a workaround that should be made more commonly known. For whatever your query is:
Query q = em.createQuery("... where col = :param");
q.setParameter("param", SOME_CONST);
q.setParameter("param", realValue);
You can first call setParameter("param",SOME_CONST) with a non-null value of the same class to invoke the type identification, then with your real potentially-null parameter. Setting the parameter a second time without having called the query is not an error. |