title: postgresql: Converting bytea to bigint
body: <p>I have to convert a bytea entry for a query to bigint. How could this be done?</p>
  
  <p><strong>More Info:</strong> </p>
  
  <p>I have a hibernate repository as below -</p>
  
  <pre><code> @Query(value = "update Sample_Table set other_id = ?1 where id = ?2", nativeQuery = true)
   void saveOrUpdateOtherId(Long other_id, Long id);
  </code></pre>
  
  <p>Hibernate somehow taking <code>id</code> (in where clause) as <code>bytea</code> and since '<em>Sample_Table</em>' has this id field as <code>bigint</code> and thus it throws type mismatch problem. </p>
  
  <p>I have tried using CAST to convert <code>bytea</code> to <code>bigint</code> but it didn't succeed and error msg says <code>bytea</code> can not be casted to <code>bigint</code>. </p>
  
  <p>How can i change <code>bytea</code> to <code>bigint</code>? </p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>Sample_Table DAO:</p>
  
  <pre><code>@Table(name = "Sample_Table")
  public class Sample{
      @Id
      @Column(name = "id", unique = true)
      @GeneratedValue
      private Long id;
  
      @Column(name = "other_id")
      private Long other_id;
  }
  </code></pre>
  
  <p><code>id</code> field is defined in here as Long.</p>
  
  <hr>
  
  <p><strong>Edit-2</strong>
  If someone get such issue, most likely he is passing null value in the query. </p>