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

  1. i createed javax.persistance.query
  2. to setparameter("param", null)
  3. 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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -