Saurabh - Thank you very much for your post.
I have to admit, it's hard to argue with that diagram,
but I�m wondering if it is giving us the full story.
Please look at "9.1.5.1 Entity bean instance�s view"
under the bullet "public void ejbPostCreate(...)"
which states:
The entity object identity is available during the
ejbPostCreate(...) method. The instance may, for
example, obtain the remote interface of the associated
entity object and pass it to another enterprise bean
as a method argument. An ejbPostCreate(...) method
executes in the same transaction context as the
previous ejbCreate(...) method.
Also see "9.5.2 Creating an entity object". This
diagram shows that business methods are not available
to the client until after postCreate completes, but
does that imply that no business methods may be
invoked on it at all (say by itself) during
postCreate?
In "9.1.5.2 Container�s view:" the bullet labeled
"public PrimaryKeyClass ejbCreate(...)" which states:
The ejbCreate(...) method returns a primary key for
the created entity object. The container creates an
entity EJBObject reference for the primary key. The
container then invokes a matching ejbPostCreate(...)
method to allow the instance to fully initialize
itself. Finally, the container returns the entity
object�s remote interface (i.e. a reference to the
entity EJBObject) to the client.
Also the end of "9.1.5.1 Entity bean instance�s view:"
in the "public void ejbStore()" bullet.
All business methods invoked between the previous
ejbLoad or ejbCreate method and this ejbStore method
are also invoked in the same transaction context.
So...
1) The EJBObject is created after ejbCreate.
2) The instance is allowed to fully initialize itself
in postCreate before the reference is presented to the
client.
3) It's valid to pass a reference to the bean to
another bean in postCreate.
4) All methods between ejbCreate and ejbStore are
executing within a transaction (including postCreate).
I realize that none of this explicitly states that
it's OK to call a business method from postCreate. On
the other hand, I can�t find anything that explicitly
says not to call business methods from within
postCreate. If business methods are allowed from
postCreate then it seems to follow that ejbLoad should
not be called without the container first calling
ejbStore (the behavior that I�m experiencing).
Thanks again for your post.
--- Saurabh Sahai <[EMAIL PROTECTED]> wrote:
> If you look at the EJB 1.1 specs 9.1.4 entity
> instance life cycle diagram, a
> business method on an entity bean can only be called
> after the instance is
> in READY state. The instance is put in the ready
> state ONLY AFTER the
> ejbPostCreate call is complete. Thus as per this
> diagram, it is not correct
> to call a business method on the bean before the
> bean's ejbPostCreate has
> completed.
>
> This is a sort of a grey area since the spec itself
> does not explicitly
> state whether it is legal or not to call a business
> method before the
> ejbPostCreate has finished, but atleast the instance
> life cycle diagram
> would imply this. It is best to use ejbPostCreate to
> only pass the remote
> reference to other beans and not to invoke business
> methods on these remote
> references before ejbPostCreate has completed
>
> An EJB container can probably handle the problem
> described here but again
> since the spec does not indicate anything explicitly
> for this case, I
> suspect different container will exhibit different
> behavior.
>
> - Saurabh
>
> ----- Original Message -----
> From: "Richard S.Martin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 15, 2002 8:25 PM
> Subject: Re: ejbLoad called on modified entity
>
>
> > Dear Fname,
> >
> > The behaviour you describe is definatly
> not right simply because
> the
> > modification to bean A never get a chance to get
> persisted before getting
> > clobbered.
> >
> > I'm guessing what is happening is that the
> App Server doesn't
> recognize that
> > it has an instance ready before the postCreate has
> finished, so it readys
> one
> > with with ejbLoad.
> >
> > Is it by any chance JRun you are using? I
> have seen a similar (but
> not quite
> > the same) wierdness with JRun calling ejbLoad when
> it shouldn't be. In the
> > end we had to move to another App Server (for
> that, and a few other
> reasons).
> >
> > Rich Martin
> >
> >
> > On Sunday 14 April 2002 13:40 pm, you wrote:
> > > Yes, I'm already implementing the workaround
> you're
> > > suggesting. My question was more with regard to
> > > whether other servers were doing this and
> whether this
> > > issue is addressed in the specification.
> > >
> > > --- Tony Michael <[EMAIL PROTECTED]>
> wrote:
> > > > What about making a flag in the EJB like below
> ??
> > > > -----------------------------
> > > > boolean check = true;
> > > >
> > > > ... ejbLoad(){
> > > > if(check){
> > > > // Do something for loading
> > > > }else{
> > > > // Don't load
> > > > }
> > > > }
> > > >
> > > > ...( ){
> > > > ...
> > > > check = false;
> > > > ...
> > > > }
> > > >
> > > > -----------------------------
> > > >
> > > > Of course, It's not that easy like above, but
> I
> > > > guess you can modify it to
> > > > work with your EJB.
> > > > You really have to be careful with that kinda
> flag.
> > > > Otherwise, your EJB
> > > > never load...
> > > >
> > > > tony
> > >
> > >
>
==========================================================================T
> > >o
> > >
> > > > unsubscribe, send email to
> [EMAIL PROTECTED] and
> > > > include in the body
> > > > of the message "signoff EJB-INTEREST". For
> general
> > > > help, send email to
> > > > [EMAIL PROTECTED] and include in the body
> of the
> > > > message "help".
> > >
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Tax Center - online filing with TurboTax
> > > http://taxes.yahoo.com/
> > >
> > >
>
===========================================================================
> > > To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the
> body
> > > of the message "signoff EJB-INTEREST". For
> general help, send email to
> > > [EMAIL PROTECTED] and include in the body of
> the message "help".
> >
> >
>
============================================================================
> ==
> > This email and any files transmitted with it are
> confidential and intended
> solely for the use of the individual or entity to
> whom they are addressed.
> All information is the view of the individual and
> not necessarily the
> company. If you are not the intended recipient you
> are hereby notified that
> any dissemination, distribution, or copying of this
> communication and its
> attachments is strictly prohibited. If you have
> received this email in error
> please notify:
> > [EMAIL PROTECTED]
> >
> >
> >
>
============================================================================
> ==
> >
> >
>
===========================================================================
> > To unsubscribe, send email to
> [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff EJB-INTEREST". For
> general help, send email to
> > [EMAIL PROTECTED] and include in the body of
> the message "help".
> >
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED]
> and include in the body
> of the message "signoff EJB-INTEREST". For general
> help, send email to
> [EMAIL PROTECTED] and include in the body of the
> message "help".
>
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".