gorm - Explain belongsTo in Grails -
from grails belongsto documentation, use of
class book { static belongsto = author }
what impact of cascading operations on book, when crud operations performed on author?
edit:
thanks responses, may didn't specify question correctly. know difference between
static belongsto [author:author]
vs
static belongsto = author
belongsto
helpful if need reference owning object. in case author
has many book
s. maybe you're using book object , want mention book instance's author
. way it.
as far crud goes, deleting or updating book not author
, deleting author
delete book
. if don't add belongsto
there no cascading saves/updates/deletes, have manually.
example:
def = new author(name: 'j.k. rawling') a.addtobooks(new book(title: 'harry potter 1')) a.addtobooks(new book(title: 'harry potter 2')) a.save() // saves author , book instances a.delete() // author , both books deleted
edit:
the op updated question, , i'm not sure answer be. burt beckwith show soon! question, op.
Comments
Post a Comment