Solved

EJB questions

Posted on 2008-10-26
1
293 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
zeroFront challenge 7 80
bunnyEars challenge 6 103
servlet requestdispatcher include and forward differences 1 25
servlet example issue 6 33
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 second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.

863 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

26 Experts available now in Live!

Get 1:1 Help Now