• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CMP EJB question

 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When is data retrieved from DB server to EJB
container while using CMP entity bean?
When findByPrimaryKey method is called to get the Local
or Remote interface, has the instance of the CMP bean been created?
Has all the data associated with this bean be retrieved from the DB server
to the EJB container? Or the data is not retrieved until the getXXX
methods are called? Thanks.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jane,
Since you asked several questions, I have quoted each one before my answer...

When is data retrieved from DB server to EJB
container while using CMP entity bean?


That depends on what EJB container you are using. Generally, the container will load the database data immediately prior to invoking the method that was requested by the client.

When findByPrimaryKey method is called to get the Local
or Remote interface, has the instance of the CMP bean been created?


Yes. In order to execute the "findByPrimaryKey()" (or any other 'finder' method), the EJB container requires an instance of the bean.

Or the data is not retrieved until the getXXX
methods are called?


Again, depends on the EJB container, but I think that generally, the data is loaded from the database while executing the 'finder' method.
Hope this helps you.
Good Luck,
Avi.
 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Avi,
I'm using Weblogic 6.1. Do you know at what
stage it retrieves data from DB server to the
EJB continer?
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a comment about invoking a "find" method: Suppose I invoke findByPrimaryKey(). The container does not need to instantiate a new bean object, go out to the database, and load all the data corresponding to this bean. It is much more likely that a container picks any arbitrary bean in the "wait pool" (beans just hanging around waiting to be used), invokes the "find" method, then returns to me the key (or keys) that I requested.
Only when you invoke an actual business method on an entity bean does a bean need to be made "method ready", having its fields synchronzied with the underlying database.


Has all the data associated with this bean be retrieved from the DB server
to the EJB container? Or the data is not retrieved until the getXXX
methods are called?


The answer to the first question is no. The container does not need to retrieve the data in the DB.
 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did SUN's spec say anything about how it
should be done?
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic