Evan Ireland wrote:
> David Sims wrote:
> >
> > Now just take it one step further. Let's say you call
> > Home.findByPrimaryKey(BAR). And suppose I secretly switch out BAR and
> > replace it with FOO. Then you still get the original FOO entity bean,
> > don't you? Even though you asked for the BAR entity bean. And because
> > we're following all the EJB rules, you can do this across JVMs and
> > across machines.
>
> It makes no difference. Even if two clients both call findByPrimaryKey(FOO),
> the server is permitted to use separate instances to service concurrent
> requests on the resulting entity object references.
sure, but the container (or database) still has to resolve any conflicts
that arise from the concurrent use of the two separate instances. In a
simple scenario, the database transaction mechanism would serialize any
changes that the two separate instances performed. So, from a logical
point of view, it's still a single bean. The bean fields that are
represented in the database would be serialized. But you're right in
that any non-database-represented fields would not behave in a singleton
fashion.
And Victor Langelo wrote:
> This would only be true if BAR.equals(FOO). Is that what you mean?
There is nothing I
> see in the spec that prohibits the server from responding to
findByPrimaryKey without
> calling bean.ejbFindByPrimaryKey.
The server could only avoid calling bean.ejbFindByPrimaryKey() if the
BAR bean were already in memory. But we never let BAR get into memory in
the first place because we always return FOO. (FOO != BAR)
However, I think you bring up a good point. Nothing in the spec says
anything (that I know of) about this last assumption. That is, the part
about "tricking" the container into always calling
bean.ejbFindByPrimaryKey(). So I think you're right in that we shouldn't
rely on this behavior.
###
And for the record, I don't have any code that makes use of this
technique. This technique was once part of an old "fun" project that has
since disappeared.
Evan and Victor, thanks for pointing out my mistakes!
cheers,
david
--
David Sims [EMAIL PROTECTED]
Sims Computing, Inc. www.simscomputing.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".