Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: hbm mapping files with enum
PostPosted: Sat Dec 17, 2011 7:24 pm 
Newbie

Joined: Wed Nov 09, 2011 7:44 am
Posts: 7
Hi, I have an enum class in java 1.5 defined like this:
public enum MyXXX {
A, B, C;
}

I want to add in the mapping hbm a derived field (called status) which should return a value of that enum type.
How should I do that?

I tried like this:
<class name="Test" table="test">

<id name="id" column="id" type="long">

<generator class="increment"/>

</id>

<property name="name" column="name" type="string" length="80"/>

<property name="status"

formula="(SELECT CASE WHEN (name = 'A') THEN 'A' WHEN (name= 'B') THEN 'B' END FROM Test t WHERE t.id = id)"

type="xxx.packeage.MyXXX"/>

</class>


What is wrong?


Top
 Profile  
 
 Post subject: Re: hbm mapping files with enum
PostPosted: Mon Dec 19, 2011 8:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Wrong forum. This should be asked on the Hibernate User Forum.


Top
 Profile  
 
 Post subject: Re: hbm mapping files with enum
PostPosted: Tue Dec 20, 2011 6:01 am 
Newbie

Joined: Wed Nov 09, 2011 7:44 am
Posts: 7
Sorry. I opened the thread in the other forum. Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.