example.cmp.single_table
Interface House

All Superinterfaces:
javax.ejb.EJBLocalObject

public interface House
extends javax.ejb.EJBLocalObject

The client's view of a row in the house table. It defines methods for the managed fields and any business methods exposed from the HouseBean implementation.

Clients always access the bean through the local interface. They never use the bean implementation. The separation between interface and implementation lets Resin-CMP insert its transaction and database caching code.

The home interface, HouseHome, is the main way to get instances of the House interface.

All local interfaces extend EJBLocalObject.


Method Summary
 void addPoints(int delta)
          A business method to add points to the house.
 java.lang.String getName()
          Returns the house name, which is the primary key of the bean.
 int getPoints()
          Returns the number of points for the house.
 
Methods inherited from interface javax.ejb.EJBLocalObject
getEJBLocalHome, getPrimaryKey, isIdentical, remove
 

Method Detail

getName

public java.lang.String getName()
                         throws javax.ejb.EJBException
Returns the house name, which is the primary key of the bean. The corresponding database column is name.

Local interfaces never define the setXXX method for the primary key.

Local methods corresponding to container managed fields never throw checked exceptions, although they may throw runtime exceptions, like EJBException.

Returns:
the house's name
Throws:
javax.ejb.EJBException - if the transaction or the database access fails. EJBException is a runtime exception.

getPoints

public int getPoints()
              throws javax.ejb.EJBException
Returns the number of points for the house. The corresponding database column is points.

The interface could also have exposed the getPoints method. This example keeps the setter hidden to motivate the addPoints business method.

Returns:
the total points for the house
Throws:
javax.ejb.EJBException - if the transaction or the database access fails.

addPoints

public void addPoints(int delta)
A business method to add points to the house.

Many updates will use business methods instead of setting the methods directly. By encapsulating the updates in business methods, applications can ensure the integrity of the database.

For example, the addPoints business method might also check the user's security and log any updates so a later audit can check who added points to the house.

Parameters:
delta - the points to add or subtract from the house.