【问题标题】:Minus and not in gorm减去而不是在gorm
【发布时间】:2013-06-04 10:58:33
【问题描述】:

我想显示未完成的投票并且当前用户没有参与这些投票。

我从以下标准开始:

def displayAdherantByVote(){
            def adherant=springSecurityService.currentUser.username

             def elec=Election.withCriteria(){
              createAlias("adherant", "adherant")
                 createAlias("candidature", "candidature")

                       eq('adherant.firstName',adherant)

               projections{
                     property('candidature.vote')

               }


def newvote(){
        def votes= Vote.createCriteria()
        def results=votes.list{
         ge("enddateelection",new Date())

           le("startdateelection",new Date())
        }

【问题讨论】:

  • 请澄清您的问题,您发布的代码太不完整。 “当前用户未参与这些投票”是什么意思?请更准确地描述您想要做的事情。
  • 如果当前用户看到一个投票并且投票仍然开放,它不会出现在这个用户中我正在寻找并且我停留在这个共享中
  • 所以,如果我理解正确的话,您希望避免显示candidature.firstnameusername 相同的选举?

标签: grails grails-orm criteria


【解决方案1】:

如果您需要在 Gorm 中对 NOT 进行否定,您可以使用:

ne(检查两个值是否不相等)

neProperty(检查两个属性是否不相等)

因此,在您的情况下,我将使用标准检查 currentUser 是否未参与投票:

neProperty("currentUser", "user")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-11
    • 2014-12-05
    • 1970-01-01
    相关资源
    最近更新 更多