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