title: Hibernate postgres bytea retrieval issue
body: <p>I am using Hibernate 4.0 to store jpegs into postgres 9.1.4 (jdbc is postgresql-9.1-901.jdbc4.jar) bytea column(byte[] is the hibernate entity, without extra type def).</p>
  
  <p>The hibernate storing process works fine because I can use Database tools to dump the bytea column and still get the jpegs. It is basically:</p>
  
  <p>In the managedBean</p>
  
  <pre><code>byte [] bytes;
  bytes = IOUtils.toByteArray(file.getInputstream());
  entity.setImage(bytes);
  </code></pre>
  
  <p>At this point, the bytes look like [-1, -40, -1, -32, 0, 16, 74, 70, ...]</p>
  
  <p>However, the problem starts with I am retrieving via hibernate. The data seems modified or corrupted somehow.</p>
  
  <pre><code>byte [] bytes;
  bytes = entity.getImage();
  </code></pre>
  
  <p>At this point, the bytes become [-26, 100, 56, 102, 102, 101, 48, 48,...]</p>
  
  <p>The hibernate getter is</p>
  
  <pre><code>@Column(name = "image")
  public byte[] getImage() {
      return image;
  }
  </code></pre>
  
  <p>Appreciate if anyone can assist, thanks!</p>