• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Hibernate EJB3 + Remote Lazy Loading Best Practices

Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

For several reasons as indicated here: http://www.hibernate.org/117.html#A36, lazy loading of remote objects is not possible with hibernate.

After much research, i have seen solutions people have come up with to solve this, such as http://h3t.sourceforge.net/. I also notice other products such as TopLink offer their own strategy to handle this (e.g. using javaagent with toplink-essentials-agent.jar).

I just wondered if anybody has any experience of this issue and how you decided to handle?

For examples sake, lets assume we have an object Order which lazy loads a collection of OrderItems. On the client (remote) site, we do a call to get the order items when needed. Using ejb3/hibernate, saying order.getOrderItems() would thrown an exception on the client (and rightly so). So what's approaches should be considered to get the order items?

Along with the solution i copied in above, of course the order items could be loaded on the server side before being returned to the client. However, let's assume we DON'T want to do this and only want to access this collection on the rare instance the order items are required (for arguments sake...).

Any experiences or points to provoke my thoughts would be greatly appreciated.

Ranch Hand
Posts: 121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my experience I solved this by (using your Order-OrderItems example):
Keep the OrderItem lazy loaded; provide a method to the client that loads the OrderItems for an specific Order, and use this method instead of the getter in the Order class.

I didn't know this H3T.
    Bookmark Topic Watch Topic
  • New Topic