markmywords
markmywords

Reputation: 663

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

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 have 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.

Upvotes: 1

Views: 157

Answers (1)

Vithun
Vithun

Reputation: 360

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

Upvotes: 2

Related Questions