title: Java byte array to Postgres JSONB
body: <p>Is there an elegant way to store java's byte array in postgres as JSONB column? </p>
  
  <p>Let's say i have the following entity:</p>
  
  <pre><code>@Entity
  @Table(name="my_table")
  public class MyEntity {
      @Id
      private Lond id;
  
      @Column(name="json_data")
      private byte[] jsonData;
  
      // getters and setters
  }
  </code></pre>
  
  <p>So <code>json_data</code> in <code>my_table</code> is a column of type JSONB. </p>
  
  <p>I use JPA and Hibernate as a provider. I have no problems with reading data, but when it comes to writing it treats <code>byte[]</code> as <code>bytea</code> (which makes sense). Can i somehow point it to JSONB instead?</p>
  
  <p>If there's no easy way, what alternatives do i have?  I know that do that by registering Hibernate's UserType, but i'd like to avoid that if possible.</p>
  
  <p>Thanks in advance.</p>