• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

1:m relationship

 
Maharaj thak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have 2 domain classes.

class User {
String name

static hasMany=[queries:Query]
static constraints = {
}

}

class Query {
String question
static constraints = {

}

I have created 1 User and 2 queries e.g.
1. How high is Mt. Everest?
2. What's the capital of Spain?

Through the scaffolded view I add both the queries to the user.But when I am trying to delete one of the queries(by going to scaffolded view for the queries) I am getting an error.Is it the default behaviour in grails or am I doing something wrong?

Regards
Maharaj thak
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few things.

1. Please UseCodeTags when posting code.
2. You said you get an error. Please TellTheDetails
3. You're missing an important piece of the puzzle.

Query should belong to a User. You should add that to your Query domain. Everything else depends on the error you are getting.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic