-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: another for persisting enumeration
PostPosted: Mon Mar 05, 2007 4:18 pm 
Newbie

Joined: Sat Oct 01, 2005 3:53 am
Posts: 5
Hi all,

I would like persist Java5 enumerations in another way.

Persisting enumeration using integer or varchar is usefull, but sometimes I thing it is not enough. Am I the only one who has this requirement ?

Here such a use case:
I have a Car object which has a TypeOfCar. I'd like to use Java5 enumeration for representing TypeOfCar. But I'd like to persist these types of car just like other entities, bound to the car with a ManyToOne association.

Using Java5 enumeration, compilation ensures that I have only 2 types of car (small, 4x4 for example).
Persisting them like other entities enable these types to have their own states, their own fields, and also some others relations.
I also imagine it would be possible to extract some parts of the ddl like data initialization (initialization of data which are required at runtime, which are constant).

Is there an elegant way for doing this with Java5 annotations ?

Thanks in advance,
Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 5:01 pm 
Newbie

Joined: Mon Mar 05, 2007 4:58 pm
Posts: 4
Enumerations don't have state, they're immutable and stateless by definition. I would suggest using a ParameterizedType that uses Generics. Then define the custom type in a Hibernate mapping with the class name of the enum as the parameter.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.