how to define one to many relationship in Grails

View: New views
4 Messages — Rating Filter:   Alert me  

how to define one to many relationship in Grails

by Mungara, Manoj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi ,

 

 

 

I am trying to create two tables through two domain classes as follows.

 

class LineOfBusiness {

                        String name

                        String description

                        static hasMany=[businessProcess:BusinessProcess]

}

 

class BusinessProcess {

            String name

            String description

            Integer lobId

            static belongsTo = LineOfBusiness

            static hasMany=[systemFunctionalArea:SystemFunctionalArea]

}

 

 

Grails is creating 3 tables Line_of_business, business_process and line_of_business_business_process.

 

Instead, what I need is there should be one-to-many from line_of_business to business_process, meaning, business_process cannot have its own existence.

 

Please throw some light how to resolve.

 

Thanks

M


Re: how to define one to many relationship in Grails

by rtayek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

At 12:09 PM 4/21/2008, you wrote:
>...
>                         static hasMany=[businessProcess:BusinessProcess]
>...            static hasMany=[systemFunctionalArea:SystemFunctionalArea]
>...
>Grails is creating 3 tables ...

you are making a many to many.

get rid of one of the hasMany's. that's what is causing the many to many.

thanks

---
vice-chair http://ocjug.org/



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: how to define one to many relationship in Grails

by sokolj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I remember I saw this issue in this forum some time ago.

The answer is that by default hibernate generates three tables even for one-to-many relations.

I think it is possible to turn off that behavior but I don't remember how. Just try to search through forum and you should find it.

Jan,
http://jan-so.blogspot.com


Mungara, Manoj wrote:
Hi ,

 

 

 

I am trying to create two tables through two domain classes as follows.

 

class LineOfBusiness {

                        String name

                        String description

                        static hasMany=[businessProcess:BusinessProcess]

}

 

class BusinessProcess {

            String name

            String description

            Integer lobId

            static belongsTo = LineOfBusiness

            static hasMany=[systemFunctionalArea:SystemFunctionalArea]

}

 

 

Grails is creating 3 tables Line_of_business, business_process and
line_of_business_business_process.

 

Instead, what I need is there should be one-to-many from line_of_business to
business_process, meaning, business_process cannot have its own existence.

 

Please throw some light how to resolve.

 

Thanks

M

Re: how to define one to many relationship in Grails

by Stephan M. February :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


----- "Manoj Mungara" <Manoj.Mungara@...> wrote:
> I am trying to create two tables through two domain classes as
>
> Grails is creating 3 tables Line_of_business, business_process and
> line_of_business_business_process.
>

Hello Manoj

I wrote a blog entry on the various quirks of one-to-many a while back:

http://blog.bruary.net/2008/03/two-ways-to-model-one-to-many-in-gorm.html

Cheers
Stephan

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email