Hi,
I've a table A with a oneToMany mapping on table B.
I use the following criteria to do a eager fetch
Code:
List<A> aList =currentSession().createCriteria(A.class).
add(Restrictions.eq("user.id", userId)).
setFetchMode("b", FetchMode.JOIN).
list();
Query wise, it does what I expected it to do, ie., used outer join to get all "A" and the "B"s corresponding to each "A"
However, I expected the object to me mapped properly. ie., if there are two matching rows in "A" and each one has two matching rows in "B" then
I expected the returned list to be of size 2 with each one having a set "B" of size 2.
However, I am actually getting a size 4 which is what the query directly returns.
Should I be doing an explicit mapping to convert the query results to domain objects. I am getting lost here