Quantcast

specify column name

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

specify column name

andresgr
Hi.

I'm trying to map legacy database.

One of the tables has a column named "rteFinal".

If i create a domain class with a property called "rteFinal" grails
(0.4 recent download) translates it to "rte_final".

Can i specify column name (something like withColumn="rteFinal")
without creating all hibernate mapping by hand?

Thanks.

--
-=-=-=-=-=-=-=-=-=-=-=-=-
Andrés González.
http://coyotevil.blogspot.com

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: specify column name

Dmitriy Kopylenko
If I'm not mistaken this is not supported at the moment, but definitely
would be nice to have "custom" mapping options be available in domain
classes kind of like the association mappings e.g. "hasMany",
"belongsTo", so there would be no need to write custom hibernate mapping
XML.

I don't remember from the top of my head: how does ActiveRecord do it?

Dmitriy.

andresgr wrote:

> Hi.
>
> I'm trying to map legacy database.
>
> One of the tables has a column named "rteFinal".
>
> If i create a domain class with a property called "rteFinal" grails
> (0.4 recent download) translates it to "rte_final".
>
> Can i specify column name (something like withColumn="rteFinal")
> without creating all hibernate mapping by hand?
>
> Thanks.
>


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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: specify column name

Dmitriy Kopylenko
Just thinking out loud. How about something like this:

class Person {

    String firstName
    String lastName
   
    def static table = 'person_tbl'
   
    def static columnMappings [firstName:first_nm, last_name:last_nm]
   
}

Dmitriy.


Dmitriy Kopylenko wrote:

> If I'm not mistaken this is not supported at the moment, but
> definitely would be nice to have "custom" mapping options be available
> in domain classes kind of like the association mappings e.g.
> "hasMany", "belongsTo", so there would be no need to write custom
> hibernate mapping XML.
>
> I don't remember from the top of my head: how does ActiveRecord do it?
>
> Dmitriy.
>
> andresgr wrote:
>> Hi.
>>
>> I'm trying to map legacy database.
>>
>> One of the tables has a column named "rteFinal".
>>
>> If i create a domain class with a property called "rteFinal" grails
>> (0.4 recent download) translates it to "rte_final".
>>
>> Can i specify column name (something like withColumn="rteFinal")
>> without creating all hibernate mapping by hand?
>>
>> Thanks.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>    http://xircles.codehaus.org/manage_email
>


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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: specify column name

andresgr
You can specify table name already with:

static withTable = "xxx"

so maybe what we need is aslo something like

static withColumnNames [...]



2007/1/18, Dmitriy Kopylenko <[hidden email]>:

> Just thinking out loud. How about something like this:
>
> class Person {
>
>     String firstName
>     String lastName
>
>     def static table = 'person_tbl'
>
>     def static columnMappings [firstName:first_nm, last_name:last_nm]
>
> }
>
> Dmitriy.
>
>
> Dmitriy Kopylenko wrote:
> > If I'm not mistaken this is not supported at the moment, but
> > definitely would be nice to have "custom" mapping options be available
> > in domain classes kind of like the association mappings e.g.
> > "hasMany", "belongsTo", so there would be no need to write custom
> > hibernate mapping XML.
> >
> > I don't remember from the top of my head: how does ActiveRecord do it?
> >
> > Dmitriy.
> >
> > andresgr wrote:
> >> Hi.
> >>
> >> I'm trying to map legacy database.
> >>
> >> One of the tables has a column named "rteFinal".
> >>
> >> If i create a domain class with a property called "rteFinal" grails
> >> (0.4 recent download) translates it to "rte_final".
> >>
> >> Can i specify column name (something like withColumn="rteFinal")
> >> without creating all hibernate mapping by hand?
> >>
> >> Thanks.
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >    http://xircles.codehaus.org/manage_email
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
-=-=-=-=-=-=-=-=-=-=-=-=-
Andrés González.
http://coyotevil.blogspot.com

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: specify column name

Dmitriy Kopylenko
Ah OK.

+1 for "withColumnNames" map.

Also how about "withSequence" for sequence id generation strategy?

D.

ndresgr wrote:

> You can specify table name already with:
>
> static withTable = "xxx"
>
> so maybe what we need is aslo something like
>
> static withColumnNames [...]
>
>
>
> 2007/1/18, Dmitriy Kopylenko <[hidden email]>:
>> Just thinking out loud. How about something like this:
>>
>> class Person {
>>
>>     String firstName
>>     String lastName
>>
>>     def static table = 'person_tbl'
>>
>>     def static columnMappings [firstName:first_nm, last_name:last_nm]
>>
>> }
>>
>> Dmitriy.
>>
>>
>> Dmitriy Kopylenko wrote:
>> > If I'm not mistaken this is not supported at the moment, but
>> > definitely would be nice to have "custom" mapping options be available
>> > in domain classes kind of like the association mappings e.g.
>> > "hasMany", "belongsTo", so there would be no need to write custom
>> > hibernate mapping XML.
>> >
>> > I don't remember from the top of my head: how does ActiveRecord do it?
>> >
>> > Dmitriy.
>> >
>> > andresgr wrote:
>> >> Hi.
>> >>
>> >> I'm trying to map legacy database.
>> >>
>> >> One of the tables has a column named "rteFinal".
>> >>
>> >> If i create a domain class with a property called "rteFinal" grails
>> >> (0.4 recent download) translates it to "rte_final".
>> >>
>> >> Can i specify column name (something like withColumn="rteFinal")
>> >> without creating all hibernate mapping by hand?
>> >>
>> >> Thanks.
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe from this list please visit:
>> >
>> >    http://xircles.codehaus.org/manage_email
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
>


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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Why only native id??

agnaldo4j
In reply to this post by Dmitriy Kopylenko
Hello all,

I be study grails code,  in
GrailsDomainConfiguration.secondPassCompile()  method use  
GrailsDomainBinder.bindClass(domainClass, super.createMappings());.

Why GrailsDomainBinder is global class?? i can't change it to use uuid
strategy id.

I think GrailsDomainConfiguration receive GrailsDomainBinder in the
contructor, in this way i can change it.

Or its is possible in another way???

obs: sorry my english.

Agnaldo
 

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Why only native id??

graemer
The implementation of GrailsDomainBinder is similar to those within
Hibernate core. They are not designed to be extended. If you want the
ability to generate a uuid mapping then there would have to be a
proposal about how that would look in GORM and then we coulld go from
there

Cheers

On 1/19/07, Agnaldo de Oliveira <[hidden email]> wrote:

> Hello all,
>
> I be study grails code,  in
> GrailsDomainConfiguration.secondPassCompile()  method use
> GrailsDomainBinder.bindClass(domainClass, super.createMappings());.
>
> Why GrailsDomainBinder is global class?? i can't change it to use uuid
> strategy id.
>
> I think GrailsDomainConfiguration receive GrailsDomainBinder in the
> contructor, in this way i can change it.
>
> Or its is possible in another way???
>
> obs: sorry my english.
>
> Agnaldo
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email

Loading...