> -----Original Message-----
> From: Jonathan Weedon [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 01, 2000 22:17
> To: [EMAIL PROTECTED]
> Subject: Re: Does it ever make sense to put a
> multi-bean-returningfindmethodin an entity bean?
>
>
> Avi Kivity wrote:
> >
> > >
> > > I believe both you and Avi are confusing what
> ejbPassivate/ejbActivate do on
> > > entity beans with what they do on stateful session beans.
> For stateful session
> > > beans, after ejbPassivate is called, the bean is
> serialized and stored to
> > > some persistent storage (typically, to the file system,
> perhaps via a database).
> > > For entity beans, however, after ejbPassivate is called,
> the entity does not
> > > have to be serialized, or stored on disk, or anything
> else. It simply moves
> > > from the "ready" bin to the "pooled" bin, which is
> probably a fairly trivial
> > > operation. There should not be any memory or disk
> overhead associated with a
> > > passivated entity bean, and thus it is certainly not
> computationally expensive
> > > to passivate.
You are correct - entity passivation indeed does not require serialization.
This leads to a new question: is the container required to call ejbStore()
even if no CMP fields have been modified, or can the container avoid the
call? Suppose doit(), below, is replaced by ejbStore(). Is the code still
broken? If so, then a nice chunck of my own code needs rewriting.
> >
> > Can you explain why EB passivation is so different?
> Consider the following:
> >
> > public class EB implements EntityBean {
> >
> > public int cmpField;
> > private int myStuff;
> >
> > // ...
> >
> > public void sneaky() {
> > myStuff = 42;
> > }
> >
> > public void doit() {
> > cmpField = myStuff;
> > }
> >
> > }
> >
> > Now suppose a client calls, in a single transaction,
> sneaky() and then
> > doit(). How can the container passivate the instance
> between those method
> > calls without losing data? Or is "private int myStuff" illegal?
> >
> > As a matter of fact, I have many lazy stores (where doit()
> is actually
> > ejbStore()). Are they all broken?
>
> Avi,
>
> It is legal, in EJB 1.1, for the above two methods to be executed as
> follows:
>
> begin transaction
> EB[1].ejbActivate()
> EB[1].ejbLoad()
> EB[1].sneaky();
> EB[1].ejbStore();
> EB[1].ejbPassivate();
> EB[2].ejbActivate();
> EB[2].ejbLoad();
> EB[2].doit();
> EB[2].ejbStore();
> EB[2].ejbPassivate();
> commit transaction
> // nothing to do here since ejbStore was already called...
>
> By this I mean that the method sneaky() is executed on on
> instance of EB (that
> is, EJ[1]) and doit() is executed on another instance (that
> is, EB[2]). Not
> that I am saying that this is a good way to write a
> container: it is not.
> However, if your code cannot run in this mode (where every
> entity bean method
> could potentially be executed on a different instance) then
> your code is not
> compliant with the EJB spec. Sorry, but it appears the your
> "private int myStuff"
> is illegal (or at least will contain undefined values),
> unless you convert it
> to a state-managed field in ejbLoad and ejbStore.
>
- Avi
--
s/\be(\w+)/e-\1/g;
===========================================================================
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".