【问题标题】:grails webflow select statement problemgrails webflow select语句问题
【发布时间】:2011-09-29 20:52:08
【问题描述】:

我在我的 grails 应用程序中使用 webflow,我有 2 个在休眠模式下具有 ManyToMany 关系的表。如您所知,这种关系创建了一个具有原始表的 2 个主键的表,它们都是第三个表的主键。

我的表是destination 和destinationGroup。

我用动态查找器编写了一个选择语句,以获得具有特定目的地的目的地组列表。 我尝试了这些方法,但对任何人都没有效果: 1-

def DestinationInstance = Destination.get(params.destination)
   flow.DestinationGroupList  = DestinationGroup.executeQuery("select distinct d.name,d.description from DestinationGroup d where d.destinations = :p",[p:DestinationInstance])

2-

def DestinationInstance = Destination.get(params.destination)
flow.destinationGroupList = DestinationGroup.findAllWhere(Destinations:destinationInstance)

3-

def DestinationInstance = Destination.get(params.destination)
   flow.destinationGroupList = DestinationGroup.findAll("from DestinationGroup as d where  d.destinations =:p", [p:destinationInstance]

)

这 3 条语句没有任何作用,如果有任何解决这个问题的原因,请告诉我。 谢谢

【问题讨论】:

  • 如果 leebutts 的回答对你有用,你应该点击他的回答旁边的复选标记接受它。

标签: grails


【解决方案1】:

您是否尝试过标准查询?

def c = DestinationGroup.createCriteria()
flow.destinationGroupList = c.list{
         destinations{
             idEq(destinationInstance.id)
         }
    }

【讨论】:

    猜你喜欢
    • 2011-05-28
    • 1970-01-01
    • 2012-08-13
    • 2023-04-11
    • 1970-01-01
    • 2012-08-05
    • 2016-04-26
    • 2014-10-07
    • 2012-05-11
    相关资源
    最近更新 更多