java - Hibernate native query optional parameter throws 'operator does not exist: bigint = bytea' -
i have query follows:
select id table1 (:param null or id_or_smth = :param)
the param
parameter optional, therefore can null
- i createed
javax.persistance.query
- to
setparameter("param", null)
- and when called
getresultlist()
got following error:
caused by: org.hibernate.exception.sqlgrammarexception: error: operator not exist: bigint = bytea
how can handle this?
hql , criteria can work when specify actual entity property/table column doesn't work:
:param null
if id_or_smth table1 column, how query should like:
query q = entitymanager.createnativequery("select id table1 id_or_smth null or id_or_smth = :param"); q.setparameter("param", paramvalye); q.getresultlist();
and paramvalue must not null.
in sql must use null/is not null, because query this:
select id table1 id_or_smth = null
will return empty result, if there rows satisfying id_or_smth null
Comments
Post a Comment