1
votes

I am new to Grails and I would like to know what impacts exist on generated code, db schema, GORM, etc. when using Grails' predefined static properties on domain classes like hasOne, hasMany and belongsTo.

For example, would hasOne force a singleton pattern somewhere?

Taking a quick look at both generated code and database, I didn't find many clues.

1
You could create a test project, use the mappings you are curious about and run the grails schema-export command to see how it changes the database.tylerwal

1 Answers

0
votes

belongsTo forces a save of the child class when saving the parent class

hasOne creates a one-to-one / one-to-many mapping in the DB (no association table)

hasMany is used for one-to-many (is in one of the classes) / many-to-many (if in both classes, with association table)