-->
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: Many-To-One enumeration class mapping?
PostPosted: Wed Mar 28, 2007 2:50 pm 
Newbie

Joined: Wed Mar 14, 2007 2:14 pm
Posts: 8
Hi,

I am using Hibernate 3.2 and ran into a problem with enum class mapping:

Assume class Person has a field gender which is a type of GENDER enum class with only two instances GENDER.MALE and GENDER.FEMALE. It also has find method as GENDER.find(String str) where str can be "m" or "f".
Further assume there is a gender table having id and value columns, and only two rows in the table: (1, 'm') and (2,'f').

Now how should I create the mapping file to get the GENDER enum class created by the find method?

<class name="Person" table="PERSON">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">ID_SEQ</param>
</generator>
</id>

<many-to-one name="gender" class="GENDER" update="false" insert="false" fetch="select">
<!-- HOW TO DO MAPPING HERE? -->
<column name="gender_id" not-null="true" />
</many-to-one>
</class>

Your help is greatly appreciated!
-Herbert


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 25, 2007 7:36 pm 
Newbie

Joined: Wed May 23, 2007 11:53 am
Posts: 12
I would also like to know how to do this. The only solution I've found so far is for the enum type to be mapped to a column in the table of its containing class.


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.