Solved

EJB questions

Posted on 2008-10-26
1
292 Views
Last Modified: 2013-11-24
If I pass an object to and EJB and the EJB changes the object.  Will I see those changes when the EJB method completes?  Does this differ when Local EJBs are used?

If I get a reference to a Stateless Session Bean and invoke two method calls.  Will those calls be guaranteed to be made on the same EJB?

0
Comment
Question by:pzaprianov
1 Comment
 
LVL 4

Accepted Solution

by:
Mr_It earned 500 total points
Comment Utility
To answer your first question:

When you use a remote business interface, a pass-by-value is involved. So when the bean modifies the object, this has no impact on the object that the client sees. Using remote interfaces implicitly provides a layer of isolation between the client and the bean.
However, with local business interfaces everything is different; a pass-by-reference is involved. So the client does see changes to the object and vice versa. If you don't want the client to modify retrieved data, you should make an explicit copy before returning it.

This is covered in the EJB Core specs (3.2.3 Choosing Between a Local or Remote Client View)

And the second question:

No, when a business method invoked on a stateless session bean completes, the bean is returned to the method-ready pool of beans. It is not guaranteed, but possible, that the same instance of the bean is used for 2 successive calls. You should never put state into a stateless session bean. If you need to preserve state between 2 successive calls, you should use a stateful session bean.

You can read in the EJB Core specs: 'There is no fixed mapping between clients and stateless instances. The container simply delegates a clients work to any available instance that is method-ready.'
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Conflicting setter definitions for property Exception 5 55
zeroMAx challenge 20 76
EvenOdd challenge 10 81
scoresIncreasing challenge 10 57
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now