Thursday, July 7, 2011

java - grails one-to-many relationship - Stack Overflow

java - grails one-to-many relationship - Stack Overflow

For testing purpose you can load some data into the bootstrap:

class BootStrap {
def init
= { servletContext ->
def writer
= new Author(name:"Jane")
writer
.save()
if(writer.hasErrors()){
println writer
.errors
}
def comic
= new Book(name: "superman", Author: writer)
comic
.save()
if(comic.hasErrors()){
println comic
.errors
}
}
def destroy
= {}
}

This way your app will have an Author and a Book in it.

Also this tutorial helped me very much.

No comments:

Post a Comment