Earn Money
Trading Forex Online
Paramount Airways
Free Data Recovery
Cargo
Job Portal
HSBC Investment
Management
Cheap Web Hosting
Make Trip
Cheap Air Travel
Leisure Hotel
Free Air Travel
Mutual Fund Informations
Cheapest Cellular Plan
Free Sexy Indians
Call Center Software
Hot Indian
|
Programming Help |
Homework Help |
Counseling
Astrology Advice |
Tarot Advice |
Parenting
Dating Advice |
Love Advice |
Divorce Advice
Legal Advice |
Debt Advice |
Career Advice
Enterprise Beans Tutorial
15
A customized exception is one that you've coded yourself, such as the InsufficentBalanceException
thrown by the debit business method of the AccountEJB example.
The javax.ejb package includes several predefined exceptions that are designed to handle common
problems. For example, an ejbCreate method should throw a CreateException to indicate an invalid input parameter.
When an enterprise bean throws an application exception, the container does not wrap it in another
exception. The client should be able to handle any application exception it receives.
If a system exception occurs within a transaction, the EJB container rolls back the transaction.
However, if an application exception is thrown within a transaction, the container does not roll back the transaction.
The following table summarizes the exceptions of the javax.ejb package. All of these exceptions are application exceptions, except for the NoSuchEntityException and the EJBException, which are system exceptions.
Exceptions
Method Name
Exception It Throws
Reason for Throwing
ejbCreate
CreateException
An input parameter is invalid.
ejbFindByPrimaryKey (and other finder methods)
ObjectNotFoundException (subclass of FinderException)
The database row for the requested entity bean is cannot be found.
ejbRemove
RemoveException
The entity bean's row cannot be deleted from the database.
ejbLoad
NoSuchEntityException
The database row to be loaded cannot be found.
ejbStore
NoSuchEntityException
The database row to be updated cannot be found.
(all methods)
EJBException
A system problem has been encountered.
Primary Key Class
You specify the primary key class with the Application Deployment Tool. When deploying the ProductEJB bean, for example, you would specify a java.lang.String as the primary key
class.
In most cases, your primary key class will be a String or some other class that belongs to the java package.
Creating a Primary Key Class
For some entity beans, you will need to define your own primary key class. if a primary key is composed of multiple fields then you must create a primary key class Primary Class Requirements
The access control modifier of the class is public. All fields are declared as public. For container-managed persistence, the field names in the primary key clsss must match the
corresponding container-managed fields in the entity bean class.
The class has a public default constructor. The class implements the hashCode() and equals(Object other) methods. The class is serializable.
Bean-Managed Persistence and the Primary Key Class
With bean-managed persistence, the ejbCreate method returns the primary key class:
|
|
|
Earn Money
Trading Forex Online
Paramount Airways
Free Data Recovery
Cargo
Job Portal
HSBC Investment
Management
Cheap Web Hosting
Make Trip
Cheap Air Travel
Leisure Hotel
Free Air Travel
Mutual Fund Informations
Cheapest Cellular Plan
Free Sexy Indians
Call Center Software
Hot Indian
|