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: How would you handle this mapping...
PostPosted: Fri Apr 25, 2008 1:40 pm 
Newbie

Joined: Wed Oct 31, 2007 1:50 pm
Posts: 13
We have a model in which we need to represent CreditCardInfo for both a users saved preferences (on file) and for a CustomerOrder. In order to do this we've done the following:

class CreditCardInfo { ... }

class CreditCardPref : CreditCardInfo { /* NOTHING */ }
class CreditCardPayment : CreditCardInfo { /* NOTHING */ }

class CustomerPreferences {
CreditCardPref { get; set; }
}

class Order {
CreditCardPayment { get; set; }
}

we do this so that we can mp the CreditCardPref and CreditCardPayment to different tables. We don't want changes to the CreditCardPref to change historic Orders, obviously. It would seem that there could be a way to use the CreditCardInfo class to map both and not have the intermediate inheritence. Is there a way? Are we on the right track?


Top
 Profile  
 
 Post subject: How would you handle this mapping...
PostPosted: Mon Apr 28, 2008 5:09 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi,

I don't think you can map a single class to two tables. You could do what you are currently doing (I think it will work OK).

Personally, I would use two separate classes (even if they share a lot of the same properties) rather than inheritance. Inheritance is used to indicate an "is a" relationship, but I suspect the classes you are describing (while sharing properties) aren't really subclasses of each other IMHO.

Regards,
Richard


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.