Solved

EJB questions

Posted on 2008-10-26
1
295 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
ID: 22829524
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bigHeights  challenge 13 62
Core Java. What output will be and why ? 6 67
groovy example issue 10 97
Windows 10 and JDK 7 7u85 4 43
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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.

809 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