title: PostgreSQL JDBC Null String taken as a bytea
body: <p>If entity.getHistory() is null following code snippet:</p>
  
  <p>(getEntityManager() returns spring injected EntityManager, database field history type is: text or varchar2(2000)</p>
  
  <pre><code>Query query = getEntityManager().createNativeQuery("insert into table_name(..., history, ....) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
  [...]
  .setParameter(6, entity.getHistory())
  [...]
  
  query.executeUpdate();
  </code></pre>
  
  <p>Gives strange exception:</p>
  
  <pre><code>17/11/11 06:26:09:009 [pool-2-thread-1]  WARN util.JDBCExceptionReporter:100 - SQL Error: 0, SQLState: 42804
  17/11/11 06:26:09:009 [pool-2-thread-1] ERROR util.JDBCExceptionReporter:101 - ERROR: **column "history" is of type text but expression is of type bytea**
  </code></pre>
  
  <p>Hint: You will need to rewrite or cast the expression.</p>
  
  <p>Problem occurred only in this configuration:<br>
  OS: CentOS release 5.6 (Final)<br>
  Java: 1.6.0_26<br>
  DB: PostgreSQL 8.1<br>
  JDBC Driver: postgresql-9.1-901.jdbc4<br>
  Application Server: apache-tomcat-6.0.28</p>
  
  <p>Everything is working fine on few other configurations or when history is empty string.
  Same statement executed from pgAdmin works fine.</p>
  
  <p>I guess problem is in PostgreSQL JDBC driver, is there some sensible reason to treat null string as a bytea value? Maybe some strange changes between Postgres 8 and 9?</p>