How to use static embedded in grails 3.3.11?

124 Views Asked by At

I am not able to embed the Address into Person. Controller and views are auto generated. When I click on create I just get a blank page instead of proper UI of grails.

package trydemo

class Person {
String name
    Address address
    static  embedded = ['address']
    static constraints = {
    }
}
package trydemo

class Address {
String city
    static constraints = {
    }
}
1

There are 1 best solutions below

0
Jeff Scott Brown On

How to use static embedded in grails 3.3.11?

Assuming you are using GORM For Hibernate, the code you show is correct and is how you use embedded in Grails 3.3.11 (or any other version).

The effect of using embedded in that way is the Address properties will be stored in the same table as the Person properties so when you retrieve a Person, there is no join or foreign key involved. All of the data to make a Person is in 1 row in 1 table.

Separate from that, you can organize your UI however you like.