How to specify foreign-key name in GORM?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to specify foreign-key name in GORM?

Tính Trương Xuân
Hi,
I have a the following mapping:
class User {
     long id
     Country country
}

class Country {
    long id
    String name
}
By default, Grails will generate the foreign-key name something like this FK183C3385A9B72 on table User, how can I specify the foreign-key name to something like FK_USER_COUNTRY?
I've search the Nabble forum and found this:
But it seems that it does not work because the current Grails version 1.3.6 does not support the 'configClass' anymore. (I've digged into the DataSource plugin of Grails)

Many thanks.
Tinh
Reply | Threaded
Open this post in threaded view
|

Re: How to specify foreign-key name in GORM?

burtbeckwith
configClass is supported, but it's not in the DataSource plugin, it's used by the Hibernate plugin - see org.codehaus.groovy.grails.plugins.orm.hibernate.HibernatePluginSupport

A custom configuration is the way to go here. I wrote up a post describing the process here: http://burtbeckwith.com/blog/?p=465

Burt

> Hi,
> I have a the following mapping:
> class User {
>      long id
>      Country country
> }
>
> class Country {
>     long id
>     String name
> }
> By default, Grails will generate the foreign-key name something like
> this FK183C3385A9B72 on table User, how can I specify the foreign-key name
> to something like FK_USER_COUNTRY?
> I've search the Nabble forum and found this:
> http://grails.1312388.n4.nabble.com/Is-it-possible-to-assign-Hibernate-foreign-key-constraint-name-td1390101.html#a1390105
> But it seems that it does not work because the current Grails version 1.3.6
> does not support the 'configClass' anymore. (I've digged into the DataSource
> plugin of Grails)
>
> Many thanks.
> Tinh
>

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

    http://xircles.codehaus.org/manage_email