-->
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: Class that implements two interfaces/Polymorphic association
PostPosted: Mon May 12, 2014 6:11 am 
Newbie

Joined: Mon May 12, 2014 5:05 am
Posts: 1
Hi,

My question is related to class with multiple implemented interfaces mapping (or in Hibernate terms, a class that extends several classes and not just one) that is not currently supported but
i would like to know if there are any recommended/working workarounds that could be used here (the <any> association mapping, etc.) or if anyone created a code patch to handle this properly.

I'm using Hibernate 4.1.7 version and have the following scenario:

ClassA with two @ManyToOne associations to interface-typed fields:

Code:
ClassA{
     @ManyToOne
     private IInterfaceA field1; //ClassB and ClassC instances can be used here
     @ManyToOne
     private IInterfaceB field2; //ClassC instances can be used here
}


ClassB and ClassC that implement the IInterfaceA and/or IInterfaceB interfaces as follows:

Code:
ClassB implements IInterfaceA
ClassC implements IInterfaceA, IInterfaceB

I would like to be able to use ClassB and ClassC instances for field1 and ClassC instances for field2 but it is not possible to map this in
hbm files as i cannot configure that ClassC "extends" IInterfaceA and "extends" IInterfaceB.

The only possible "workaround" that i've identified for now is using the <any> association type for field1 and field2. Knowing that the <any> association
has the following issues: no FK constraints and no EAGER fetch mode (see https://hibernate.atlassian.net/browse/HHH-3574")

Could you please tell me:

1. If the <any> solution is the only available solution and if it is an appropriate approach in this case? if not, could you then please explain what you have done to solve this?
2. If someone was able to patch the Hibernate code in order to achieve this (!?): a class having several extended classes has most probably a huge impact on the Hibernate code or cannot be mapped to tables ...
3. If Hibernate teams are planning to provide this functionality in any future releases.

Thank you


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.