While generating a controller and a viewing error: Can not set the int field lms.Book.bookId to java.lang.Class

advertisements

While generating controller and view for a Domain class as:

class Book {

    static constraints = {
        bookId blank:false
        bookTitle blank:false
    }

    private int bookId
    private String bookTitle
    private String author
    private double price
    private Date edition
    private String publisher
}

Giving Error saying : Can not set int field lms.Book.bookId to java.lang.Class


I think if u add 'private' to field declaration, u have to write getter and setter for this field:

class Book {

    static constraints = {
        bookId blank:false
        bookTitle blank:false
    }

    private Integer bookId
...
    Integer getBookId() { this.bookId }

    void setBookId(Integer bookId) { this.bookId = bookId }
....
}