• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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.

Thanks!
 
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.
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic