• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate eager fetching

 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Player object that holds on to an address. When I retrieve the Player object from the database, it doesn't automatically retrieve the Address objects associated to it. What is the correct way to enable eager fetching for an object such that I don't have to do something like

Player p = ... retrieve from database ...
p.getAddress().getCity(); // force load of address object by referencing it

Thanks
Brian
 
Nick Heudecker
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just set the "lazy" attribute on the <many-to-one> element:

<many-to-one lazy="false"...>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic