I have a parent-child-grandchild relationship (A-B-C). A can have many Bs and B can have many Cs. B and C have composite ids. B has (A_id, B_id) as PK and C has (A_id, B_id, C_id) as PK. (This is a legacy schema with natural business keys throughout). All ids are assigned.
My problem is that when I load C using session.createQuery(..), Hibernate runs queries to load A and B too. I have set lazy="true" and outer-join="false" in all mapping files. I am 100% certain I am not accessing A and B at all. I also tried session.createCriteria(..).setFetchMode(..) but no effect. No matter what I do, it wants to load A and B.
Is there a way out? Could the fact that I am using composite ids have anything to do with this? At this point, I have to resort to straight JDBC to avoid the extra queries, any help will be very much appreciated.
Thanks
|