-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to map enum property to field of type char
PostPosted: Wed Jun 27, 2007 1:47 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Hello,

I would like to map an enum property to a field of my database of type char ? What should I write to the mapping file ?

thanks,

mathmax


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 4:55 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
You should write an EnumUserType, see http://www.hibernate.org/272.html for more informations about this.

A UserType is quite easy to implement and let you deal absolutely how you want with your data and the way they must be persisted.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 5:33 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Hello batmat.

I have a problem :

I guess I should define a user type like this :

<typedef name="ESex" class="EnumUserType">
<param name="enumClass">ESex</param>
<param name="identifierMethod">ToString</param>
<param name="valueOfMethod">fromString</param>
</typedef>

identifierMethod permit to cast from string to enum type
and valueOfMethod permit to cast enum type to string.

But where to define those methods ?

Batmat, I'm french too. I would feel more comfortable if I could speech french with you. May I write you an e-mail you speech by msn ?

thank you for your help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.