Test your skills through the online practice test: EJB Quiz Online Practice Test

Related differences

EJB 1.0 vs EJB 2.0EJB 2.0 vs EJB 3.0EJB 3.0 vs Spring
JavaBeans vs EJB

Ques 71. What is the difference between Message Driven Beans and Stateless Session beans?

In several ways, the dynamic creation and allocation of message-driven bean instances mimics the behavior of stateless session EJB instances, which exist only for the duration of a particular method call. However, message-driven beans are different from stateless session EJBs (and other types of EJBs) in several significant ways: Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls. Message-driven beans have no home or remote interface, and therefore cannot be directly accessed by internal or external clients. Clients interact with message-driven beans only indirectly, by sending a message to a JMS Queue or Topic. Only the container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary. The Container maintains the entire lifecycle of a message-driven bean; instances cannot be created or removed as a result of client requests or other API calls.

Is it helpful? Add Comment View Comments
 

Ques 72. Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.This has to be consider as passed-by-value, that means that it’s read-only in the EJB. If anything is altered from inside the EJB, it won’t be reflected back to the HttpSession of the Servlet Container.The pass-by-reference can be used between EJBs Remote Interfaces, as they are remote references. While it is possible to pass an HttpSession as a parameter to an EJB object, it is considered to be bad practice in terms of object-oriented design. This is because you are creating an unnecessary coupling between back-end objects (EJBs) and front-end objects (HttpSession). Create a higher-level of abstraction for your EJBs API. Rather than passing the whole, fat, HttpSession (which carries with it a bunch of http semantics), create a class that acts as a value object (or structure) that holds all the data you need to pass back and forth between front-end/back-end. Consider the case where your EJB needs to support a non HTTP-based client. This higher level of abstraction will be flexible enough to support it.

Is it helpful? Add Comment View Comments
 

Ques 73. What is the difference between find and select methods in EJB?

A select method can return a persistent field (or a collection thereof) of a related entity bean. A finder method can return only a local or remote interface (or a collection of interfaces).

Because it is not exposed in any of the local or remote interfaces, a select method cannot be invoked by a client. It can be invoked only by the methods implemented within the entity bean class. A select method is usually invoked by either a business or a home method.

A select method is defined in the entity bean class. For bean-managed persistence, a finder method is defined in the entity bean class, but for container-managed persistence it is not.

Is it helpful? Add Comment View Comments
 

Ques 74. What is the difference between JavaBean and EJB?

A Java Bean is a software component written in the Java programming language that conforms to the JavaBeans component specification. The JavaBeans APIs became part of the “core” Java APIs as of the 1.1 release of the JDK.

The JavaBeans specification defines a Java-based software component model that adds a number of features to the Java programming language. Some of these features include:
.introspection
.customization
.events
.properties
.persistence

Enterprise JavaBeans (EJBs) are Java-based software components that are built to comply with Java’s EJB specification and run inside of an EJB container supplied by a J2EE provider. An EJB container provides distributed application functionality such as transaction support, persistence and lifecycle management for the EJBs.

Is it helpful? Add Comment View Comments
 

Ques 75. What is abstract schema?

Abstract schema is part of an entity bean’s deployment descriptor which defines the bean’s persistent fields and their relationship. Abstract schema is specified for entity beans with container managed persistence. We specify the name of the Abstract schema name in the deployment descriptor. The queries written in EJB QL for the finder methods references this name. The information provided in this Abstract Schema is used by the container for persistence management and relationship management.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: