Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails使用预先存在的SQL联接表链接表_Sql_Grails_Join_Groovy - Fatal编程技术网

Grails使用预先存在的SQL联接表链接表

Grails使用预先存在的SQL联接表链接表,sql,grails,join,groovy,Sql,Grails,Join,Groovy,我有三个表,场景,表单和一个链接表来连接这两个,一个表单可以属于多个场景,一个场景可以有多个表单,链接表保存关系信息。。。在Grails中如何实现这一点?我无法改变现有表格的结构…:/ 链接表的结构很简单: form_id (matches PK of form table) test_scenario_id (matches the PK on the test scenario table) [order] (defines the order in which the forms shou

我有三个表,场景,表单和一个链接表来连接这两个,一个表单可以属于多个场景,一个场景可以有多个表单,链接表保存关系信息。。。在Grails中如何实现这一点?我无法改变现有表格的结构…:/

链接表的结构很简单:

form_id (matches PK of form table)
test_scenario_id (matches the PK on the test scenario table)
[order] (defines the order in which the forms should display)
在普通的旧SQL中,我可以使用如下连接,但不知道如何将其转换为Groovy speak:-

select lnk_scenario_form.test_scenario_id, dbo.lnk_scenario_form.[order], dbo.form.form_id
from dbo.form
JOIN lnk_scenario_form on form.form_id = lnk_scenario_form.form_id 
JOIN dbo.test_scenario on dbo.test_scenario.test_scenario_id = lnk_scenario_form.test_scenario_id
where lnk_scenario_form.test_scenario_id = SCENARIO ID
order by lnk_scenario_form.[order];
以下是我目前开设的课程:-

class Form {


    static constraints = {
        formDesc(blank:false,maxSize:100)
        }

    static mapping = {
        table "form"
        version false
        columns{
            id column:"form_id"
            formDesc column:"description"
        }
    }

    String formDesc
}


看,干杯,我来看看,看起来好得难以置信!O.O
package fartframework

class TestScenario {


    static constraints = {
        testscenariodesc(blank:false, maxSize:100, unique: true)
        browser(inList:["RND","FF","CH","IE"], blank:false)
        myrelease(blank:false, maxSize:10)
        system(blank:false, maxSize:50)
        subSystem(blank:false, maxSize:50)
    }

    static mapping = {
        table "test_scenario"
        version false
        columns{
            id column:"test_scenario_id"
            testscenariodesc column:"description"
            browser column:"browser"
            myrelease column:"release"
            system column:"system"
            subSystem column:"subSystem"
        }
    }

    String testscenariodesc
    String browser
    String myrelease
    String system
    String subSystem

    String toString (){
        "${testscenariodesc}"
    }

}