title: ERROR: COALESCE types bytea and character varying in PostgreSQL
body: <p>I write a postgresql and pass parameter <code>name1</code> from my java code with Spring + Hibernate.</p>
  
  <pre><code>SELECT * FROM Test
  WHERE name = COALESCE(:name1, name2)
  </code></pre>
  
  <p>but i got an error</p>
  
  <pre><code>ERROR: COALESCE types bytea and character varying
  </code></pre>
  
  <p>The type of <code>name1</code> is String in my java code.</p>
  
  <p>I tried to solve the problem</p>
  
  <pre><code>COALESCE(convert_from(:name1,'UTF8'), name2)
  </code></pre>
  
  <p>It will pass JUNIT Test in Eclipse. However when I run it on Tomcat, I will get an error</p>
  
  <pre><code>Error:convert_from(character varying, unknown) not exist
  </code></pre>
  
  <p>How to solve it? Thanks.</p>