【问题标题】:Retrieve first 10000 records from the database - grails从数据库中检索前 10000 条记录 - grails
【发布时间】:2014-09-06 11:19:37
【问题描述】:

我有一个名为News 的课程。该域类的属性如下所示。

String name
String age
Chat chat

我在数据库中为上述课程保存了几条记录。现在我想检索它的前 10000 条记录并显示在下面。

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

我得到的只是一个错误:

//groovy.lang.MissingMethodException: 没有方法签名: com.project.mine.Chat.plus() 适用于参数类型: (java.lang.String) 值:[%]

【问题讨论】:

  • 您如何期待“聊天”上的点赞,这是一个聊天对象? like 用于文本/字符串值。你想完成什么?
  • 我想检索所有具有相同chatIDnamechatID 是在Chat 中找到的属性)。我该怎么做?

标签: grails groovy


【解决方案1】:

根据 cmets 中的更多信息,您似乎正在寻找类似这样的标准:

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

【讨论】:

    猜你喜欢
    • 2011-08-20
    • 2011-11-29
    • 1970-01-01
    • 1970-01-01
    • 2019-05-04
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    相关资源
    最近更新 更多