-->
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: Override Association in Subclass
PostPosted: Mon Jan 15, 2007 4:38 pm 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Hi,

I have an abstract base class that contains a many-to-many association. However, in one of my subclasses, I need to change this association to a one-to-many as I have extra data that I need to store along with each associated object.

Am I able to easily override this? How would I change the mapping in the joined-subclass element so that it gets overridden with the new type of association?

I tried just re-declaring the association in the mapping file but then I got a "Found shared references to a collection" exception.

Am I tackling this in the right way or is there a better way to handle this?

Thanks,

Jason


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 8:35 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
Well one strategy would be to ditch the abstract class and use an interface instead. Then, using a mapping file for each class that implements the interface you would be able to declare that association appropriately. However, I realize this method looses the effeciencies of the abstract class. I'd be interested to see what ideas others have here.

-devon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 8:42 pm 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Thanks Devon...this is an idea that I hadn't considered.

There is an awful lot of stuff in the abstract class that is common for all of the subclasses so I don't want to ditch it entirely. I could however create an interface for just this association and then implement that independantly in each subclass.

Will be interested to see any alternative options too although this is looking pretty good so far.

Cheers,

Jason


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