Full topic is : how to define fetch profile in hibernate mapping on hierarchical entities
Hi, I have a class hierarchy like
Code:
class A
{
B b;
}
Code:
interface B
{}
Code:
class C implements B
{
}
Code:
class D implements B
{
}
In my hibernate mapping file for entity A, the defenition is like;
Code:
<any id-type="long" name="b" meta-type="int" cascade="none">
<meta-value value="1" class="C"/>
<meta-value value="2" class="D"/>
<column name="BTYPE" length="2"/>
..
</any>
I want to fetch entity A with its value which implements B eagerly, sometimes I dont want. So I need to use a fetch profile(also I dont want duplicate HQL methods for this):
Code:
<fetch-profile name="a-with-b">
<fetch association="b" style="join"/>
</fetch-profile>
But this doesn't work because of b. What sholud be done for this situation?