0

I'm using the below code to retrieve a file from db using Spring Boot JPA. But it's returning null value.

PS. There is no problem with DB connection. I can save values using the repository but problem occurs while retrieving value using ID.

Can anyone please give me a solution ?

@RequestMapping(value = "/fetch/{id}", method = RequestMethod.GET)
public List<Page> getData(@PathVariable String id) {
     try {
            FileDB file = fileRepository.findOne(Long.parseLong(id));
            Document doc = file.getDocument();
            List<Page> pages = doc.getPages();
            return pages;

        } catch (Exception e) {
            System.out.println(e.toString());
            List<Page> pages = new ArrayList<>();
            return pages;
        }
}

0 Answers0