hibernate - HQL returns duplicate objects -
i have 2 questions regarding hql usage
i have query below, returns duplicate rows/objects, adding distinct keyword solves problem can explain, why need distinct here, can't without it?
select st state st inner join fetch st.cities
the hql documentation says
a fetch join not need assign alias, because associated objects should not used in clause (or other clause).
but why can't use associated objects in clause, if want eagerly fetch want add condition how it?
simply because that's how hql , jpql specified: 1 element returned per row of jdbc resultset, unless use distinct.
because if allowed add restrictions on fetched entities, break invariants of entities themselves, hibernate, , own code, assume verified: cities returned
state.getcities()
cities of state. of them. not ones happen obey criteria of random query.
Comments
Post a Comment