Enterprise Beans Tutorial

Home| Forums | Join Google Group | Join Yahoo Group | Jobs
Get custom programming done at GetAFreelancer.com!
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


11 o If an ejbCreate method cannnot create an entity because another entity with the same primary key already exists, it should throw a javax.ejb.DuplicateKeyException (a subclass of
CreateException).
o If a client receives a CreateException or a DuplicateKeyException, it should assume that the entity was not created. o The state of an entity bean may be directly inserted into the database by a non-J2EE application. Although the entity bean for this row was not created by an ejbCreate method, the
bean can be located by a client program.
The ejbPostCreate Method · For each ejbCreate method, you must write an ejbPostCreate method in the entity bean class. · The EJB container invokes ejbPostCreate immediately after it calls ejbCreate. Unlike the ejbCreate
method, the ejbPostCreate method can invoke the getPrimaryKey and getEJBObject methods of the
EntityContext interface
· Often, your ejbPostCreate methods will be empty. · The signature of an ejbPostCreate must meet the following requirements: o The number and types of arguments must match a corresponding ejbCreate method. o The access control modifier must be public. o The method modifier cannot be final or static. o The return type must be void. o The throws clause may include the javax.ejb.CreateException, and other exceptions that are specific to your application. The ejbRemove Method A client removes an entity bean by invoking the remove method.
This invocation causes the EJB client to call the ejbRemove method, which deletes the entity state from the
database. If the ejbRemove method encounters a system problem, it should throw the javax.ejb.EJBException. If it encounters an application error, it should throw a javax.ejb.RemoveException. An entity bean may also be removed directly by a database deletion. The ejbLoad Method and ejbStore Methods · If the EJB container needs to synchronize the instance variables of an entity bean with the
corresponding values stored in a database, it invokes the ejbLoad and ejbStore methods.
· The ejbLoad method refreshes the instance variables from the database, and the ejbStore method writes
the variables to the database.
· The client may not call ejbLoad and ejbStore. · If a business method is associated with a transaction, the container invokes ejbLoad before the business
method executes.
· Immediately after the business method executes, the container calls ejbStore. · Because the container invokes ejbLoad and ejbStore, you do not have to refresh and store the instance
variables in your business methods-- the container performs these functions for you.
· If the ejbLoad and ejbStore methods cannot locate an entity in the underlying database, they should
throw the javax.ejb.NoSuchEntityException. This exception is a subclass of EJBException. Because
EJBException is a subclass of RuntimeException, you do not have to include it in the throws clause.
When NoSuchEntityException is thrown, the EJB container wraps it in a RemoteException before
returning it to the client.
The Finder Methods The finder methods allow clients to locate entity beans.
For every finder method available to a client, the entity bean class must implement a corresponding method
that begins with the prefix ejbFind. The finder methods specific to your application, such as ejbFindByLastName and ejbFindInRange, are optional, but the ejbFindByPrimaryKey method is required. As its name infers, the


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