-->
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 a class to different tables
PostPosted: Thu Apr 09, 2009 6:10 pm 
Newbie

Joined: Thu Apr 09, 2009 6:08 pm
Posts: 2
Hi,

I have following modeling problem:

I have a java class, let's name it "class A", with 3 attributes (attr1, attr2 and attr3). This class is represented by 2 tables in the database: tableX and tableY. TableX and TableY have each 3 fields. TableX has field1X, field2X and field3X. TableY has field1Y, field2Y and field3Y. I'd like to have class A to hold the information from the 3 fields coming from tableY and tableX. Is there a way to do it without subclassing class A?

The name of the fields are different on tableX and tableY but they can be "stored" by class A because they hold the same information and have the same type. @AttrbuteOverrides apparently could do the job but I'd have to subclass class A, wouldn't I?

And of course.. I cannot change the DB.

My real problem is a bit more complicated than that actually. I have a whole class model (about 10 classes) with the same problem and they are all connected thru some sort of relationship.

I'm using Hibernate 3.4 annotations.

Thanks for any ideas!

Ken


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.