При запросе к БД выдает ошибку

При запросе к БД , функция должна найти отчет в таблице Report для формирования из него файл json.Но при вводе id возникает ошибка "Hibernate:

    SELECT
        r. id,
        r.data 
    FROM
        Report r  
    WHERE
        r.id = ?
2024-01-18T17:13:49.699+05:00 ERROR 5904 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [byte] for value [24655]] with root cause

java.lang.NumberFormatException: Value out of range. Value:"24655" Radix:10 "
@Entity
@Table(name = "report")
public class Report {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Lob
    @Column(name = "data", columnDefinition = "text")
    private byte[] data;

    public Report() {
    }

    public Report(byte[] data) {
        this.data = data;
    }

    public Report(Long id, byte[] data) {
        this.id = id;
        this.data = data;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }
}
public interface ReportRepository extends JpaRepository<Report, Integer> {
    @Query(value = "SELECT * FROM Report", nativeQuery = true)
    List<Report> findAllReport();

    @Query(value = "SELECT r.data FROM Report r  WHERE r.id = :id", nativeQuery = true)
    byte[] findGetReport(@Param("id") Long id);
}
@RestController
@RequestMapping("/report")
public class ReportController {

    private ReportService reportService;

    public ReportController(ReportService reportService) {
        this.reportService = reportService;
    }

    @PostMapping()
    public ResponseEntity<Long> statisticReport() throws JsonProcessingException {
        return new ResponseEntity<>(reportService.generatedStatisticReported(), HttpStatus.OK);
    }


    @GetMapping(value = "/{id}/dowload")
    public ResponseEntity<Resource> dowloadFile(@PathVariable Long id)throws IOException {
        String nameFile = "Statistic.json";
        Resource resource = new ByteArrayResource(reportService.findGetReport(id));
        return ResponseEntity.ok()
                .header(HttpHeaders.CONTENT_DISPOSITION,"attachment; filename = \"" + nameFile + "\"")
                .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                .body(resource);
    }
}
@Service
public class ReportServiceImpl implements ReportService {

    private EmployeeRepository employeeRepository;

    private PositionRepository positionRepository;
    private ReportRepository reportRepository;

    public ReportServiceImpl(EmployeeRepository employeeRepository,
                             PositionRepository positionRepository, ReportRepository reportReposotory) {
        this.employeeRepository = employeeRepository;
        this.positionRepository = positionRepository;
        this.reportRepository = reportReposotory;
    }

    @Override
    public List<Report> findAllReport() {
        return reportRepository.findAllReport();
    }



    @Override
    public byte[] findGetReport(Long id) throws IOException {

        return reportRepository.findGetReport(id);

    }

}

Ответы (0 шт):