tenwit wrote:
Sorry, still can't parse that. Perhaps you could illustrate this without explanation. Can you provide
- a sample DB table (with just enough rows to show the problem),
- the mapping for the table,
- the query that is producing the wrong results,
- the results that the query is producing, and
- the results that you would like to see.
Hi tenwit
thank you so much for replying again and again. now currently i have this table category reference itself
now i am using this one to many mapping but recursively.
using the hql
getHibernateTemplate().find("select c from category as c inner join fetch c.childs as ch where c.parentId = 0"); //identify the root
not this row returning
example
parent data -> child data
CPU -> Intel CPU
CPU -> AMD CPU
now i want to have this data
CPU ->parent single only
but when i get the childs with c.getChilds()
it's returning
Intel CPU
AMD CPU
currently based on the sql that is generated hibernate getting the child as well in one go, that's why we are having this CPU category two times.
now i trick hibernate a bit by using "Group by" and it's returning single parent and single child only either Intel CPU or AMD CPU
is there anyway that i could get only CPU but when i want to get the childs it;s returning all the childs
cheers