简体   繁体   中英

Domain classes in grails

How to make relationship between two domain classes in grails . I already have one domain class from the plugin (spring security plugin) and i want to link USER domain class from plugin to the Profile domain class . What is the best way to do it?

See the GORM documentation for a good overview. For a one-to-one relationship as I assume a profile would be, you could simply do the following:

class User {
    Profile profile
}

class Profile {
    // only needed if you need to refer to user from the Profile instance
    static belongsTo = [user:User] 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM