Results 1 to 3 of 3

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

  1. #1

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3

    Default

    Thank you very much!!!!

    that was exactly what I was looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •