Dear all,
I'm a bit curious why Hibernate doesn't do fetch join or subselect when I told it to do so.
I have an entity T with some subclasses (T1, T2 ...) mapped using Joined inheritance. T has one-to-one relationship with another entity U using:
Code:
@ManyToOne(fetch=FetchType.EAGER)
From the document, if I retrieve T, U should be retrieved with T by using join. However, Hibernate is using another select to get U.
My query is like:
Code:
"select t from T where ... order by ..."
and I get one select for U for each T returned from the above query.
I try to change the query to:
Code:
"select t from T left join fetch t.u where ... order by ..."
and:
Code:
"select t from T fetch all properties where ... order by ..."
but Hibernate is still doing the same.
I try to add
Code:
@Fetch(FetchMode.JOIN)
to the association, but it doesn't help (nor does BatchSize).
There is another relation on U to V (ManyToMany Set) that has similar problem. On this relation, @FetchMode doesn't work (both JOIN and SUBSELECT), but @BatchSize do work.
Is this Hibernate's optimization for DB2 or I am doing something wrong?
I'm using:
- Hibernate 3.2.6
- Hibernate EntityManager 3.3.2
- DB2Dialect, DB2 Express-C v9
Thank you in advance,
Pongtawat