小编R-S*_*eah的帖子

在grails中保存具有多对多关系的对象

我正在尝试保存具有很多关系的对象.SellingCompany可以拥有多个账户,账户可以与许多销售公司相关联.因此,存储在SellingCompaniesAccount中的表之间存在许多关系

我的Account_Info域名如下:

class AccountInfo { 
    static mapping ={
        table 'AccountInfo'
        version false
        //id column:'accountInfoID'
    }

    String evi_pass_phrase
    String evi_username
    String security_key

    // to make sure fields show up in a particular order

    static constraints = {
        //accountInfoID(insert:false,update:false)
        evi_pass_phrase()
        evi_username()
        security_key()

    }

    static hasMany = [sellingcompaniesaccount:SellingCompaniesAccount]


    String toString() {
        return "${evi_username}"
    }
}
Run Code Online (Sandbox Code Playgroud)

我的SellingComapanies域名如下:

class SellingCompanies 
{

    static mapping = {  
        table 'SellingCompanies'
        version false
    }

    String name

    //static belongsTo = AccountInfo

    //static hasMany = [accounts: AccountInfo]
    static hasMany = [sellingcompaniesaccount:SellingCompaniesAccount] …
Run Code Online (Sandbox Code Playgroud)

grails groovy save has-many

6
推荐指数
1
解决办法
3445
查看次数

标签 统计

grails ×1

groovy ×1

has-many ×1

save ×1