0
votes

I have a class called News. The properties of this domain class are shown below.

String name
String age
Chat chat

I have saved several records in the database for the above class. Now i want to retrieve the first 10000 records of it and display below.

    def news = News.createCriteria().list (max: 10000, offset: 5) {
        like("chat", Chat.get(chatId)+"%")
    }

All what i get is an error :

//groovy.lang.MissingMethodException: No signature of method: com.project.mine.Chat.plus() is applicable for argument types: (java.lang.String) values: [%]

1
How are you expecting a like on "chat" which is a Chat object to work? like is for text/string values. What are you trying to accomplish? - Joshua Moore
I want to retrieve all name that has the same chatID (chatID is a property found in Chat). How can i do this ? - Illep

1 Answers

1
votes

Based on further information in the comments, it would appear you are looking for a criteria something like this:

def news = News.createCriteria().list(max: 10000, offset: 5) {
  chat {
    eq("chatId", chatId) // assumes that chatId isn't the id of the Chat domain.
  }
}