0
votes

I am learning to use Grails with i18n-fields plugin. It a simple setup, domain:

package bookstore

@i18nfields.I18nFields
class Book {
    String name 

    static constraints = {
    }

    static i18nFields = ['name']
}

And controller is: package bookstore

class BookController {
    def scaffold = Book

    def test = {
        def tekst = ""
        Book.findAll(sort: 'name').each{ tekst += "id: " + it.id + "    book: " + it.name + "<br/>\n" }
        render tekst
    }
}

I created few books through scaffold generated interface, which is ok. Problem is with action 'test'. Without sort it works but when I add sort condition it breaks with message:

Error 500: Internal Server Error

URI

/BookStore/book/test

Class

org.hibernate.QueryException

Message

could not resolve property: name of: bookstore.Book

Around line 8 of grails-app\controllers\bookstore\BookController.groovy

How to resolve this?

1

1 Answers

0
votes

Use the fallowing code insted of Book.findAll(sort:'name')

Book.list(sort: 'name')