如何查找域对象关联类参数?

时间:2016-04-12 10:48:26

标签: grails

我有域类workpackage,activity和aw。
如何从workpackage获取活动id值。

class Aw {

    Activity activity    
    static hasMany=[activity:Activity]    
    Workpackage workpackage 

    static belongsTo=[workpackage:Workpackage]

    static constraints = {

        workpackage nullable:true    
        activity nullable:true
    }
}

1 个答案:

答案 0 :(得分:0)

Workpackage有很多活动。就是这样。没有PW或AW类。如果您想从活动中获取项目ID,只需写入 def myactivity = Activity.get(passed_id); def wanted_id = my_activity.workpackage.project.id.

如果我没有正确理解这个问题,请详细解释。