-->
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: Need to Map Odd Table Structure - Any Ideas??
PostPosted: Tue Mar 14, 2006 2:01 am 
Newbie

Joined: Wed Feb 15, 2006 7:51 pm
Posts: 9
Location: Sydney, Australia
I'm trying to map a legacy database structure into a new Hibernate-based application. I can't figure out how (or if it's possible) to map one particular aspect of it.

There are three tables involved:
Employee
- employeeId
- name
- dateOfBirth
- employeeNumber
Visitor
- visitorId
- name
- dateOfBirth
- referralCode
Accident
- victimType
- victimId

There are two types of persons: Employees and Visitors. Either may have an accident, so the Accident table has a column for the victim (person) type and Id.

In Java, I wanted to create a Person interface that the Employee and Visitor classes would implement. Then the Accident objects wouldn't need to know the type of Person that had the Accident. And I want Hibernate to look after instantiating the appropriate type (Visitor or Employee) depending on the value of the victimType column.

Any ideas on how this can be accomplished?
thanks!
thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 9:59 pm 
Newbie

Joined: Wed Feb 15, 2006 7:51 pm
Posts: 9
Location: Sydney, Australia
am i missing something simple here, or is it actually not doable?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 11:01 pm 
Newbie

Joined: Tue Mar 14, 2006 10:02 pm
Posts: 2
Your old relation data model must be normal form or hibernate won't work well.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.