• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Lazy Load in Entity Beans Relationship

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way of saying to the container that I want a "lazy load" of entity beans in a relationship (like I can do in Hibernate)?

Tanks
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Entity Beans naturally are "lazy loaders". A CMR field holds a reference to a local component interface or a collection of local interfaces. The (related) entity itself is only loaded by the container once you invoke a business method through that local interface.

I anything, a vendor extension (not the spec) may allow you to specify eager-loads of entities that you will most likely need - as long as you can guarantee that the EJB Server is total control of that portion of the underlying persistent store - so that it doesn't waste time on unnecessary ejbLoads().
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed, most application servers allow you to influence the loading strategy for entity beans that participate in relationships (via their local business interfaces). You can have lazy-loading (my guess this is a natural default, since it usually provides optimal performance when dealing with multiple relationships), and eager-loading . With eager-loading, use it as "full" (i.e. when a bean gets loaded, load all beans that participate in a relationship with the first bean, even indirectly) with caution, since it can easily generate a whole bunch of ejbLoad() calls and unnecessary bean instances (especially when we�re dealing with many-to-many or many-to-one relationships). Of course, the lazy-loading tradeoff is more computation during bean access. It is up to you to dig in the AS documentation and see what can and what can not be done and decide your strategy. Just remember that loading strategies and a number of other optimizations are beyond (i.e. not specified) in the ejb specification. That leaves room for the AS vendors to optimize and make us AS users happier (at least in theory)
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic