see below
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Tom Jordan
> Sent: Wednesday, October 06, 1999 10:07 PM
> To: [EMAIL PROTECTED]
> Subject: Entity bean performance and Session Wrappers
>
>
> Hi,
>
> I am new to ejb and have a couple of questions about using Entity
> beans. I
> have read the archives with some saying session beans should always wrap
> entity beans and others saying that its okay to directly use entity beans.
>
> I just wrote my first entity bean called Product using CMP and a
> test class
> to make sure it does what its suppose to and it does except the
> performance
> is terrible. Using a sql profiler I can tell that for every
> getXXX() method
> that is called, there is a separate database call that is reselect all the
> fields in the bean. Is this suppose to happen and if so how can I control
> this behavior so that calling 5 getMethods does not create 5
> database hits.
> I am using TX_Required as the default for the bean.
>
See the next section
> Another question and I think that it may be related to the 1st is
> the notion
> wrapping entity beans with sessions. Surely its is not suggested that all
> the get and set methods of an entity be replicated on the
> session. An while
> it may be necessary to use session beans to control the
> interaction between
> several beans, there are often situations where you need to do a series of
> gets on a bean to show the user. So how do we achieve this.
Your right, they are related. Your session bean would probably not have a
getter/setter for every accessor on the entity bean. Your session bean would
act as a concentrator with methods that take objects (structs) or multiple
parameters. This method on the session bean would access an entity bean
class (could be one of many instances) and invoke the entity's accessors via
its remote interface.
Each of these accesses would take place on the *session's* original
transaction. An ejbLoad() for an entity only takes place (normally) for the
first access following a *new* transaction. Similarly, when the sessions
transaction ends (it's accessor finishes) the transaction ends. At this time
ejbStore() is invoked on the entity bean.
When a client results invokes a series of single accessors on an entity
bean, you get the results you are seeing. Each access begins and ends a
transaction, resulting in, at the very least, an ejbLoad for each getter,
and an ejbLoad *and* ejbStore for each setter. Not usually a real world
scenario.
> I have reviewed the sample at
> http://www.execpc.com/~gopalan/java/session.html notice that he provides a
> method like getProduct() which would return a reference to the product
> interface (which is really an entity bean).
> In this situation would the object be passed by value or would it be a
> remote reference to an entity bean? would you still be able to do get an
> sets on this object and use it like an entity bean?
This rule holds true whenever you encounter this scenario in RMI. If the
return type (class or interface) has java.rmi.Remote as a superclass, the
object will be passed by remote-reference. Otherwise, it is passed by value.
jim
===========================================================================
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".