I have a question regarding Eager fetching and the SQL-strategy used by Hibernate (I'm using annotations).
I have a hierarchy of Entitys mapped to diffrent tables:
Code:
class A { }
class B extends A { }
when I do a query over the main-entity I get (as expected) a list of instaces of diffrent types (A and B).
Each of the types are also mapped to diffrent 'type' entitys like with many-to-one:
Code:
class A {
@ManyToOne(fetch = FetchType.EAGER)
private RegionType regionType;
}
when doing like this I expected that the "RegionType" should be fetched in the same database query as the Entity with this Annotation (A above) but it is not. Instead I get one sql-query fething the RegionType for each fetched A. Since I fetch quite many A and I also use the RegionType for each A (so LAZY is not really an option) this renders very many sql-querys, not that good .. so ...
Is this how it is? Is there any way to get Hibernate to join the RegionType with the main sql query?
Thanks,
/Magnus