41.What is a transaction?A transaction is a single unit of work items which follows the ACID properties. ACID stands for Atomic, Consistent,Isolated and Durable. 42.What ACID stands for?ACID stands for Atomic, Consistent,Isolated and Durable.
43.What is Container Managed Transactions?In this type, container manages the transaction states. 44.What is Bean Managed Transactions?In this type, developer manages the life cycle of transaction states. 45.Which are the attributes of Container Managed Transactions?EJB 3.0 has specified following attributes of transactions which EJB containers implement:
46.Which are the attributes of Bean Managed Transactions?In Bean Managed Transactions, Transactions can be managed by handling exceptions at
application level. Following are the key points to be considered:
47.Which are the attributes of Container Managed Security?EJB 3.0 has specified following attributes/annotations of security which EJB containers implement:
48.What is JNDI? Explain its terms in terms of EJB.JNDI stands for Java Naming and Directory Interface. It is a set of API and service interfaces. Java
based applications use JNDI for naming and directory services. In context of EJB, there are two
terms:
EJB 3.0 provides option to define database entity relationships/mappings like one to one, one to many, many to one and many to many relationships. Following are the relevant annotations:
49.What is EJBQL?EJB 3.0, ejb query language is quite handy to write custom queries without worrying about underlying database details. It is quite similar to HQL, hibernate query language and is often referred by name EJBQL. 50.What is Application level Exception in EJB?If business rule is voilated or exception occurs while executing the business logic. Then EJB container treats it as Application level exception. 51.What is System level Exception in EJB?Any exception which is not caused by business logic or business code. RuntimeException, RemoteException are SystemException. For example, error during ejb lookup.Then EJB container treats such exception as System level exception. 52.How EJB Container handles exceptions?When Application Exception occurs, ejb container intercepts the exception but returns the same to
the client as it is. It does not roll back the transaction unless it is specified in code by
EJBContext.setRollBackOnly method. EJB Container does not wrap the exception in case of
Application Exception. 53.How does EJB support polymorphism? Because an EJB consists of multiple “parts”, inheritance is achievable in a rather limited fashion (see FAQ answer on inheritance here).
There have been noteworthy suggestions on using multiple inheritance of the remote interface to achieve polymorphism, but the problem of how to share method signatures across whole EJBs remains to be addressed.
The following is one solution to achieving polymorphism with Session Beans. It has been tried and tested on WebLogic Apps Server 4.50 with no problems so far.
54.What classes does a client application need to access EJB?It is worthwhile to note that the client never directly interacts with the bean object but interacts with distributed object stubs or proxies that provide a network connection to the EJB container system.
The mechanhism is as follows.
55.What is an EJB primary key? How is it implemented when the database doesn’t have a primary key?A primary key is an object that uniquely identifies the entity bean. According to the specification, the primary key must be unique for each entity bean within a container. Hence the bean’s primary key usually maps to the PK in the database (provided its persisted to a database). You may need to create a primary key in the database for the sake of referential integrity. This does not, however, mean you NEED a primary key in the database. As long as the bean’s primary key (which maps to a column or set of columns) can uniquely identify the bean it should work. 56.What’s an .ear file?An .ear file is an “Enterprise Archive” file. The file has the same format as a regular .jar file (which is the same as ZIP, incidentally). The .ear file contains everything necessary to deploy an enterprise application on an application server. It contains both the .war (Web Archive) file containing the web component of the application as well as the .jar file. In addition there are some deployment descriptor files in XML. 57.Is method overloading allowed in EJB?Yes you can overload methods. 58.How can JMS be used from EJB 1.1?The same as any client would use JMS. At this point there is no integration, but it is planned for a future release of the EJB spec. 59.Can primary keys contain more than one field?Yes, a primary key can have as many fields as the developer feels is necessary, just make sure that each field you specify as the primary key, you also specify a matching field in the bean class. A primary key is simply one or more attributes which uniquely identify a specific element in a database. Also, remember to account for all fields in the equals() and hashCode() methods 60.How does Container Managed Persistence work with automatically generated database ID fields? Should I map the ID field explicitly or leave it unspecified?In the Deployment Descriptor, map the normal fields appropriately, but don’t specify the auto-id field as one of the container managed fields. |