Best pattern for persistent enums properties?

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

Best pattern for persistent enums properties?

Marc Palmer Local
Hi,

I can't see a nice way, due to Groovy's lack of enums, to leverage  
Hibernate's enum support. Using int properties seems nasty.

Thanks in advance for any insights.

Marc


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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Best pattern for persistent enums properties?

graemer
Well the way I tend to do this is using an inList constraint:

String name

def constraints = {
       name(inList:['fred','bob','joe'])
}

Grails will validate that it has one of those values when save() is called

Graeme

On 6/26/06, Marc Palmer <[hidden email]> wrote:

> Hi,
>
> I can't see a nice way, due to Groovy's lack of enums, to leverage
> Hibernate's enum support. Using int properties seems nasty.
>
> Thanks in advance for any insights.
>
> Marc
>
>
> ---------------------------------------------------------------------
> 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
|

Re: Best pattern for persistent enums properties?

Marc Palmer Local

On 26 Jun 2006, at 21:33, Graeme Rocher wrote:

> Well the way I tend to do this is using an inList constraint:
>
> String name
>
> def constraints = {
>       name(inList:['fred','bob','joe'])
> }
>
> Grails will validate that it has one of those values when save() is  
> called
Yes, I thought of something like that. With int values for enum  
values you could use 'range' too. I suppose in this case I suppose I  
could do:

> def constraints = {
>       name(inList:MY_ENUM.stringValues())
> }
>
...or something like that. I wonder how performant this is in  
Hibernate compared to using true JDK 1.5 enums.

Marc


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

    http://xircles.codehaus.org/manage_email