title: PostgreSQL throws "column is of type jsonb but expression is of type bytea" with JPA and Hibernate
body: <p>This is my entity class that is mapped to a table in <code>postgres</code> (9.4)
  I am trying to store metadata as <code>jsonb</code> type in the database</p>
  
  <pre><code>@Entity
  @Table(name = “room_categories”)
  @TypeDef(name = “jsonb”, typeClass = JsonBinaryType.class)
  public class RoomCategory extends AbstractEntity implements Serializable {
      private String name;
      private String code;
      @Type(type = "jsonb")
      @Column(columnDefinition = "json")
      private Metadata metadata;
  
  }
  </code></pre>
  
  <p>This is the metadata class:</p>
  
  <pre><code>public class Metadata implements Serializable {
      private String field1;
      private String field2;
  
  }
  </code></pre>
  
  <p>I have used following migration file to add <code>jsonb</code> column:</p>
  
  <pre><code>databaseChangeLog:
  – changeSet:
  id: addColumn_metadata-room_categories
  author: arihant
  changes:
  – addColumn:
  schemaName: public
  tableName: room_categories
  columns:
  – column:
  name: metadata
  type: jsonb
  </code></pre>
  
  <p>I am getting this error while creating the record in <code>postgres</code>:
  ERROR: column “metadata” is of type <code>jsonb</code> but expression is of type <code>bytea</code>
  Hint: You will need to rewrite or cast the expression.</p>
  
  <p>This is the request body i am trying to persist in db:</p>
  
  <pre><code>  {
      “name”: “Test102”,
      “code”: “Code102”,
      “metadata”: {
      “field1”: “field11”,
      “field2”: “field12”
      }
      }
  </code></pre>
  
  <p>Please help how to convert <code>bytea</code> type to <code>jsonb</code> in java spring boot app</p>