Interview Questions

The home of a Product CMP entity bean has a finder method, which returns an Enumeration of all the products ...

BEA WebLogic Questions and Answers


(Continued from previous question...)

The home of a Product CMP entity bean has a finder method, which returns an Enumeration of all the products ...

The home of a Product CMP entity bean has a finder method, which returns an Enumeration of all the products whose price falls below a certain value, which is passed as the method argument. If there are no products in the database to match the above criteria what will be the result of a call to this finder method?
a. EJBException is thrown
b. ObjectNotFoundException is thrown
c. NoSuchEntityException is thrown
d. An empty enumeration is returned


Choice D is correct. Find methods that return a single remote reference throw a FinderException if an application error occurs and a ObjectNotFoundException if a matching bean cannot be found. The ObjectNotFoundException is a subtype of FinderException and is only thrown by find methods, which return single remote references.
The findByPrimaryKey() method returns only one remote reference since there is a one-to-one relationship between a primary key's value and an entity. Find methods that return an Enumeration or Collection type return an empty collection or enumeration if no matching beans can be found or throw a FinderException if an application error occurs. NoSuchEntityException is a system exception thrown by the ejbLoad() method of an entity bean when the database row to be loaded is not found and also by the ejbStore() method when the database row to be updated cannot be found. It is a subclass of EJBException.

(Continued on next question...)

Other Interview Questions