• Post Reply Bookmark Topic Watch Topic
  • New Topic

CMP EJB question  RSS feed

 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • 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.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Rich Raposa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Did SUN's spec say anything about how it
should be done?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!