开发者

Grails: Create and save 1:1 domain relation with a single form

开发者 https://www.devze.com 2023-03-05 17:41 出处:网络
I am new to Grails and currently stuck at the following problem: I have two models \"BasicData\" and \"ExtendedData\". In BasicData.groovy I have defined the 1:1 via extended = ExtendedData

I am new to Grails and currently stuck at the following problem: I have two models "BasicData" and "ExtendedData". In BasicData.groovy I have defined the 1:1 via extended = ExtendedData

Now I ha开发者_运维技巧ve read that I can simply save them both by invoking the BasicData Controller but only thing I get is a nasty Exception message with no real explanation of the error.


You should define the 1:1 in BasicData this way:

class BasicData {
    ExtendedData extended
    ... //other declarations
}

Are you sure this is how you have done it? Also, depending on your requirements you might have to add a belongsTo attribute in you ExtendedData class. Read more about 1:1 associations in section 5.2.1.1 here: http://grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html

0

精彩评论

暂无评论...
验证码 换一张
取 消