title: How to retrieve blob from server using JPA repository in spring
body: <p>I've created spring application for CRUD. I can easily write into server data like string,Long,blob but When I try to retrieve it from server. I've encountered with difficulty which byte array from server gives in BigInteger from server. How I could get data in byte array instead of BigInteger?When I write in insert byte array this data which column is BLOB. Here is my code</p>
  
  <p><strong>Repository</strong></p>
  
  <pre><code>public interface ArriveRepository extends JpaRepository&lt;ArriveEntity,Long&gt;
  { 
      @Query(value = "select arrive.time,air_lines.image,arrive.flight,arrive.destination_uzb," +
              "arrive.destination_eng,arrive.destination_rus,arrive.status,arrive.status_time " +
              "from arrive inner join air_lines on air_lines.id = arrive.airline_id where arrive.arrive_date = (:date1)",nativeQuery = true)
      List&lt;Object[]&gt; getForArriveTerminal(@Param("date1") LocalDate date1);
  }
  </code></pre>
  
  <p>When I retrieve data from server I'm using this class</p>
  
  <p><strong>ArriveTerminalDto</strong></p>
  
  <pre><code>public class ArriveTerminalDto {
     private String time;
     private BigInteger logo;
     private String flight;
     private String destinationUzb;
     private String destinationEng;
     private String destinationRus;
     private String status;
     private String statusTime;
    //getter setter}
  </code></pre>
  
  <p><strong>Service class</strong></p>
  
  <pre><code>  public List&lt;ArriveTerminalDto&gt; getToShow(LocalDate date1)
      {
          List&lt;ArriveTerminalDto&gt; list = new ArrayList&lt;&gt;();
          List&lt;Object[]&gt; list1 = arriveRepository.getForArriveTerminal(date1);
          for(Object[] objects: list1)
          {
              ArriveTerminalDto arriveTerminalDto = new ArriveTerminalDto();
              arriveTerminalDto.setTime((String)objects[0]);
              arriveTerminalDto.setLogo((BigInteger) objects[1]);
              arriveTerminalDto.setFlight((String) objects[2]);
              arriveTerminalDto.setDestinationUzb((String) objects[3]);
              arriveTerminalDto.setDestinationRus((String) objects[4]);
              arriveTerminalDto.setDestinationEng((String) objects[5]);
              arriveTerminalDto.setStatus((String) objects[6]);
              list.add(arriveTerminalDto);
          }
          return list;
      }
  </code></pre>
  
  <p>This code works but it didn't give me byte array from server.
  When I try to change BigInteger into byt[] array it gives me following errors
  from postman</p>
  
  <pre><code>{
      "timestamp": "2019-01-28T09:33:52.038+0000",
      "status": 500,
      "error": "Internal Server Error",
      "message": "java.math.BigInteger cannot be cast to [B",
      "path": "/arrive/terminal/date=2019-01-27"
  }
  </code></pre>
  
  <p>Changed Object into ArriveTerminalDto but still it give error my following repo</p>
  
  <pre><code>public interface ArriveRepository extends JpaRepository&lt;ArriveEntity,Long&gt;
  {
  
      @Query(value = "select arrive.time,air_lines.image,arrive.flight,arrive.destination_uzb," +
              "arrive.destination_eng,arrive.destination_rus,arrive.status,arrive.status_time " +
              "from arrive inner join air_lines on air_lines.id = arrive.airline_id where arrive.arrive_date = (:date1)",nativeQuery = true)
      List&lt;ArriveTerminalDto&gt; getForArriveTerminal(@Param("date1") LocalDate date1);
  }
  </code></pre>