    All Examples  All EJB Examples  This Package

## Class examples.ejb.extensions.finderEnumeration.AccountBean

    java.lang.Object
        |
        +----examples.ejb.extensions.finderEnumeration.AccountBean

public class AccountBean
extends java.lang.Object
implements javax.ejb.EntityBean

AccountBean is an EntityBean. This EJBean illustrates:

- EJBean-managed persistence and transactions; the code in this file directly accesses the data storage.
- Application-defined exceptions.

##

AccountBean()

##

balance()
  Returns current balance.
deposit(double)
  Adds amount to balance.
ejbActivate()
  Required by the EJB specification, this method is not used by this example.
ejbCreate(String, double)
  This method corresponds to the create method in the home interface "AccountHome.java".
ejbFindAccountsWithBalance(double)
  Finds all EJBeans with a balance equal to a given amount.
ejbFindAndLoadAccountsWithBalance(double)
  Finds all EJBeans with a balance equal to a given amount.
ejbFindByPrimaryKey(String)
  Attempts to find the EJBean with a given Primary Key from the persistent storage.
ejbLoad()
  Loads the EJBean from the persistent storage.
ejbPassivate()
  This method is required by the EJB Specification, but is not used by this example.
ejbPostCreate(String, double)
  Required by the EJB specification, this method is not used by this example.
ejbRemove()
  Deletes the EJBean from the persistent storage.
ejbStore()
  Stores the EJBean in the persistent storage.
setAccountId(String)
setBalance(double)
setEntityContext(EntityContext)
  Sets the EntityContext for the EJBean.
unsetEntityContext()
  Unsets the EntityContext for the EJBean.
withdraw(double)
  Subtracts amount from balance.

##

AccountBean

    public AccountBean()

##

setEntityContext

    public void setEntityContext(javax.ejb.EntityContext ctx)

Sets the EntityContext for the EJBean.
  Parameters:
    `ctx` - EntityContext

unsetEntityContext

    public void unsetEntityContext()

Unsets the EntityContext for the EJBean.

ejbActivate

    public void ejbActivate()

Required by the EJB specification, this method is not used by this example.

ejbPassivate

    public void ejbPassivate()

This method is required by the EJB Specification, but is not used by this example.

ejbLoad

    public void ejbLoad()

Loads the EJBean from the persistent storage.
  Throws:
    javax.ejb.NoSuchEntityException - if the bean is not found in the database
    javax.ejb.EJBException - if there is a communications or systems failure

ejbStore

    public void ejbStore()

Stores the EJBean in the persistent storage.
  Throws:
    javax.ejb.NoSuchEntityException - if the bean is not found in the database
    javax.ejb.EJBException - if there is a communications or systems failure

ejbCreate

    public java.lang.String ejbCreate(java.lang.String accountId,
                            double initialBalance) throws javax.ejb.CreateException

This method corresponds to the create method in the home interface "AccountHome.java". The parameter sets of the two methods are identical. When the client calls `AccountHome.create()`, the container allocates an instance of this bean and calls `AccountBean.ejbCreate()`.

For bean-managed persistence, `ejbCreate()` returns a primary key, unlike the case of container-managed persistence, where it returns a void.

  Parameters:
    `accountID` - String Account ID
    `initialBalance` - double Initial Balance
  Returns:
    String Primary Key
  Throws:
    javax.ejb.CreateException - if there is a problem creating the bean
    javax.ejb.DuplicateKeyException - if a create is attempted using a Primary Key already in the database
    javax.ejb.EJBException - if there is a communications or systems failure

ejbPostCreate

    public void ejbPostCreate(java.lang.String accountId,
                              double initialBalance)

Required by the EJB specification, this method is not used by this example.
  Parameters:
    `accountID` - String Account Identification
    `initialBalance` - double Initial Balance

ejbRemove

    public void ejbRemove()

Deletes the EJBean from the persistent storage.
  Throws:
    javax.ejb.NoSuchEntityException - if the bean is not found in the database
    javax.ejb.EJBException - if there is a communications or systems failure

ejbFindByPrimaryKey

    public java.lang.String ejbFindByPrimaryKey(java.lang.String pk) throws javax.ejb.ObjectNotFoundException

Attempts to find the EJBean with a given Primary Key from the persistent storage.
  Parameters:
    `pk` - String Primary Key
  Returns:
    String Primary Key
  Throws:
    javax.ejb.ObjectNotFoundException - thrown if the EJBean cannot be found
    javax.ejb.EJBException - if there is a communications or systems failure

ejbFindAccountsWithBalance

    public java.util.Enumeration ejbFindAccountsWithBalance(double findBalance)

Finds all EJBeans with a balance equal to a given amount. Returns an Enumeration of found EJBean primary keys.
  Parameters:
    `findBalance` - double Test Amount
  Returns:
    Enumeration EJBean Primary Keys
  Throws:
    javax.ejb.EJBException - if there is a communications or systems failure

ejbFindAndLoadAccountsWithBalance

    public weblogic.ejb.pstore.FindEnumeration ejbFindAndLoadAccountsWithBalance(double findBalance)

Finds all EJBeans with a balance equal to a given amount. Returns a WebLogic FindEnumeration of WebLogic KeyValuePairs. Each KeyValuePair is made up of a found EJBean primary key and its corresponding bean. Returning a FindEnumeration will cause the EJB container to load each bean into the EJB cache.
  Parameters:
    `findBalance` - double Test Amount
  Returns:
    weblogic.ejb.pstore.FindEnumeration Enumeration of weblogic.ejb.pstore.KeyValuePairs.
  Throws:
    javax.ejb.EJBException - if there is a communications or systems failure

deposit

    public double deposit(double amount)

Adds amount to balance.
  Parameters:
    `amount` - double Amount
  Returns:
    double balance

withdraw

    public double withdraw(double amount) throws ProcessingErrorException

Subtracts amount from balance.
  Parameters:
    `amount` - double Amount
  Returns:
    double Balance
  Throws:
    ProcessingErrorException - if Amount > Balance.

balance

    public double balance()

Returns current balance.
  Returns:
    double Balance

setBalance

    public void setBalance(double balance)

setAccountId

    public void setAccountId(java.lang.String accountId)

    All Examples  All EJB Examples  This Package