|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
example.cmp.single_table.HouseBean
Implementation of the HouseBean. Each instance of HouseBean maps to a table entry of "house", where house is defined as
CREATE TABLE house ( name VARCHAR(250), points INTEGER )
The bean implementation is abstract and the get and set methods for the managed fields are abstract to take advantage of Resin-CMP's container-managed persistence. All business methods must be fully implemented. Resin-CMP will create the implementation of the abstract methods.
Resin-CMP will cache the bean instance. Once the instance is loaded, it can avoid calling the database for any further calls.
HouseBean extends the AbstractEntityBean implementation. AbstractEntityBean is a stub EntityBean implementation with default methods to make life a little more sane for simple beans.
Constructor Summary | |
HouseBean()
|
Method Summary | |
void |
addPoints(int delta)
Business method to add a number of points to the house. |
abstract java.lang.String |
getName()
Returns the house name. |
abstract int |
getPoints()
Returns the number of points for the house. |
abstract void |
setName(java.lang.String name)
Sets the house name. |
abstract void |
setPoints(int points)
Sets the number of points for the house. |
Constructor Detail |
public HouseBean()
Method Detail |
public abstract java.lang.String getName()
public abstract void setName(java.lang.String name)
In this example, the setName method is optional since it doesn't have a create method. setName would be used in a create method to set the primary key for the new item. Beans must never call setName in any other situation than the create method.
The set methods for the primary key are never exposed in the local interface.
name
- the name for a new house instance.public abstract int getPoints()
With Resin-CMP's caching, this will normally not require a new database call after the first request.
public abstract void setPoints(int points)
addPoints
. Clients must
call addPoints
to change the house's points.points
- the new number of points for the house.public void addPoints(int delta)
Because the getPoints and setPoints calls are contained in the same business method call, it's in the same transaction. That means the update will be consistent even with multiple threads.
The automatic transaction is like a synchronize call, but is more efficient and potentially capable of handling distributed updates.
delta
- the points to add or subtract.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |