Grails linking tables using pre-existing SQL join table -


i've got 3 tables, scenarios, forms , link table connect two, form can belong multiple scenarios, , scenario can have multiple forms, link table holds relationship information... how do in grails? can't alter structure of tables exist... :/

the structure of link table simply:

form_id (matches pk of form table) test_scenario_id (matches pk on test scenario table) [order] (defines order in forms should display) 

within plain old sql can utilise join follows have no idea how translate groovy speak: -

select lnk_scenario_form.test_scenario_id, dbo.lnk_scenario_form.[order], dbo.form.form_id 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 lnk_scenario_form.test_scenario_id = scenario id order lnk_scenario_form.[order]; 

here classes have set far: -

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 } 

and

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}"     }  } 


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -