I have such mapping:
<subclass entity-name="StructuralConstraint" ...
...
<bag name="typeReferences" fetch="subselect" lazy="true" cascade="merge,persist,save-update,lock,refresh" table="structuralconstraint_placementtype">
<key/>
<many-to-many entity-name="PlacementType" unique="false"/>
</bag>
...
</subclass>
but when I have loaded some StructuralConstraints and try to get typeReferences for all of them I see that there are many queries:
Hibernate: select typerefere0_.id as id3_, typerefere0_.elt as elt3_, placementt1_.`id` as id1_50_0_, placementt1_.e_version as e3_50_0_, placementt1_.`name` as name4_50_0_, placementt1_.`base_id` as base5_50_0_, placementt1_.`abstract` as abstract6_50_0_, placementt1_.`reportingattribute_id` as reportin7_50_0_, placementt1_.`modified` as modified8_50_0_, placementt2_.`id` as id1_50_1_, placementt2_.e_version as e3_50_1_, placementt2_.`name` as name4_50_1_, placementt2_.`base_id` as base5_50_1_, placementt2_.`abstract` as abstract6_50_1_, placementt2_.`reportingattribute_id` as reportin7_50_1_, placementt2_.`modified` as modified8_50_1_, reportinga3_.`id` as id1_70_2_, reportinga3_.e_version as e3_70_2_, reportinga3_.`name` as name4_70_2_, reportinga3_.`value` as value5_70_2_, reportinga3_.`modified` as modified6_70_2_
from structuralconstraint_placementtype typerefere0_ left outer join `placementtype` placementt1_ on typerefere0_.elt=placementt1_.`id` left outer join `placementtype` placementt2_ on placementt1_.`base_id`=placementt2_.`id` left outer join `reportingattribute` reportinga3_ on placementt2_.`reportingattribute_id`=reportinga3_.`id` where typerefere0_.id=?
But there must be only one query for this association cause it is subselect fetching and I loose time.
Can anybody help?
Thanks
|