Announcement Announcement Module
Collapse
No announcement yet.
getting to an association w/o using lazy=false in hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting to an association w/o using lazy=false in hibernate

    I realize this might not be the right place to ask this, but I thought I might give it a shot.

    Is there a way to get to an association from an hql query? Currently I have lazy set to false. I don't want to have the caller of my dao method responsible for opening a session to get to a reference. How can i make sure the caller will have the reference available without making the association non-lazy. I assume I can write a HQL query to ensure the association is there.


    thanks in advance,
    Mike

  • #2
    Yes - you can use the FETCH keyword,

    from Company LEFT JOIN FETCH company.employees WHERE company = :name
    See the Hibernate reference documentation - it explains this and what other means you have to eagerly fetch the associations of an entity.

    Comment


    • #3
      Thank you very much!!!!

      that was exactly what I was looking for.

      Comment

      Working...
      X