Choosing among ejbSelect or find?

Alessandro A. Garbagnati

The ejbSelectXXX() and findXXX are very similar methods, and the main difference is that the first one is not exposed through the client interface, that means that it cannot be called by a client directly, unless wrapped in a method.
There is another interesting difference related to the transaction context under wich an ejbSelectXXX() or findXXX() method is executed.
The ejbSelectXXX() methods are executed in the transaction context of the method that is actually using it, while the findXXX() execute according to their own attributes (as specified by the bean provider).

Nikos Argiropoulos has also added two additional differences:
The ejbSelectXXX() method can return a single or a collection of objects of any type e.g Strings when the finded returns only single or collection of component or local component interfaces.
When calling the ejbSelectXXX method from the wrapping business method, you can pass to it arguments related with the particular instance of the EJB. In the findXXX this cannot be done.

Deciding when to use one and when the other, is really up to the developer. The ejbSelectXXX() seems to be a little bit more powerful. Is important to remember that it cannot be used by the client.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.