'Using a Long type element in API and passing the long type to MySQL database Error

I made a Restful API with Spring Boot. One of my methods is to post and book with an ISBN (10 digit integer) number with type of Long. and pass it to the mySQL database. In the database I use bigint(20) to get the data. However it is doesn't pass the value to the database, instead, it only gives 0 to the value. I tried using String of the ISBN value but it is not working, the string will be null in SQL and throw an exception. I am wondering what would be the error in my code?

In the Book Class I have:

public class Book {
    private int id;
    private Long ISBN;
    private String title;
    private String author;
    private String description;
    private String publishedDate;
    private String publisher;

Function to create a Book:

public int createBook(Book book){
    jdbcTemplate.update("INSERT into book(ISBN, title, author, 
    description,publishedDate,publisher) VALUES(?,?,?,?,?,?)",
    book.getISBN(), book.getTitle(), book.getAuthor(), book.getDescription(), 
    book.getPublishedDate(), book.getPublisher());
    return jdbcTemplate.queryForObject("SELECT max(id) from book", Integer.class);
}

Controller to post a book:

@PostMapping("/book")
public ResponseEntity<Integer> createBook(@RequestBody Book book){
    return new ResponseEntity<>(service.createBook(book), HttpStatus.CREATED);
}

Thank you for your answers!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source