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.  [ 1 post ] 
Author Message
 Post subject: mapping database lookup to jpa entities
PostPosted: Tue Mar 04, 2008 3:20 am 
Newbie

Joined: Tue Mar 04, 2008 2:50 am
Posts: 1
I have the following database tables: lookup and employee.

Lookup Table: structure with sample data.

class_name * value * description
----------------------------------------------
SEX_CODE * 1 * Male
SEX_CODE * 2 * Female
BANK_CODE * 1 * HSBC
BANK_CODE * 2 * CityBank

Employee Table: structure with sample data.

id * name * sex_code * bank_code
--------------------------------------------
1 * Yusuf * 1 * 1
2 * Maher * 1 * 2
3 * Suzan * 2 * 1

What is the best way to map them into jpa entities?

I tried to map an abstract class to lookup table and use class_name column as discriminator for the subclasses Sex and Bank and reference the bank and sex as ManyToOne in the employee object.. but I'm getting a class cast exception when the sex_code and bank_code has the same value.

I tried to create views Sex_lookup and Bank_lookup and map them directly to entities. again hibernate complains that he can't find a table with such name.

Help please.


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

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.