my dog learned polymorphism
The moose likes Groovy and the fly likes 1:m relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "1:m relationship" Watch "1:m relationship" New topic

1:m relationship

Maharaj thak

Joined: Jul 29, 2010
Posts: 27
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?

Maharaj thak
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

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.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: 1:m relationship
It's not a secret anymore!