grails - using multiple belongsTo, but only one at a time

做~自己de王妃 提交于 2019-12-03 16:34:24

The domain class definitions that you have posted seem correct based on your requirements. One modification that I'd make here would be to add a custom validator to make sure that both order and member are not null at the same time.

    static constraints = {

    order(nullable: true, validator: {field, inst -> inst.member || field})
    member(nullable: true)

    } 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!