java - Hibernate get object with linked objects -
i have problem hibernate mapping , queries. have object have relation b , c.
the fetch mode lazy (@manytoone(fetch = fetchtype.lazy)
) , can't change it. problem next:
when object method (hibernatedao.get
), object whitout relation b , c.
if create criteria, force relation criteria.setfetchmode(...)
query. have read on web it's not thing make criteria object primary key.
how method ?
thanks.
you can use fetch profiles have fetch mode set lazy default, , eager specific query: http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e3524
and if using hibernate version doesn't supports fetch profiles, can hql query retrieves tree need, using joins.
but have read on web it's not thing make criteria object primary key.
i careful before ruling out solution because read somewhere it's "bad". may bad thing in end, if don't understand why bad, may ruling out solution made specific case ;-)
Comments
Post a Comment