Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.webapps.bean
Interface EntityBean  view EntityBean download EntityBean.java

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
Actor, DBFile, Duplicable, SequenceBean, TrackedUser, User, Versioned
All Known Implementing Classes:
Address, AuditedExtension, ModeratedExtension, ServletFile, Session, SimpleActor, SimpleDBFile, SimpleTrackedUser, SimpleUser, TreeExtension, UserGroup, UserGroupType, VersionedExtension

public interface EntityBean
extends java.io.Serializable

A javabean must implement this interface in order to be handled by the EntityBeanStore.

As well as implementing this interface, all Entity Beans must define the following two constructors:

Entity beans usually have other methods for getting various children or parent beans, and which access the database. The golden rule in these cases is that, wherever possible, beans should only know about their own database tables. If they require access to other tables then this should be done via static methods on the appropriate beans. (Obviously this breaks down where a join between two or more entity tables is required, but the intention is still that access to particular tables should be restricted to particular beans.)

Version:
$Id: EntityBean.java,v 1.6 2003/09/30 15:13:09 joe Exp $

Field Summary
static java.lang.String DATABASE_TABLE
          The name of a table (in the default database) that indexes this bean type.
static java.lang.String INTERFACE_BEAN
          The name of the interface that this bean implements, and which will be used to key this bean on the session.
static int NULL_ID
           
 
Method Summary
 void delete()
          Delete this bean from the database.
 int getId()
          Get the unique id of this bean instance.
 void save()
          Save this bean to the database.
 void setId(int id)
          Set the unique id of this bean instance.
 

Field Detail

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
The name of a table (in the default database) that indexes this bean type. This table must have a PK column called "id" and a row for each of the beans of this type.

See Also:
Constant Field Values

INTERFACE_BEAN

public static final java.lang.String INTERFACE_BEAN
The name of the interface that this bean implements, and which will be used to key this bean on the session. This field should only be defined in those situations where a bean interface will only have ONE concrete implementation in the application. If an interface may have more than implementation then the application will have to use an IndexedEntityBeanStore in order that the type can be disambiguated.

See Also:
Constant Field Values

NULL_ID

public static final int NULL_ID
See Also:
Constant Field Values
Method Detail

getId

public int getId()
Get the unique id of this bean instance.


setId

public void setId(int id)
Set the unique id of this bean instance.


save

public void save()
          throws java.sql.SQLException
Save this bean to the database.


delete

public void delete()
            throws java.sql.SQLException
Delete this bean from the database. It is up to the particular subclass whether the bean is deleted the database entirely, or just marked as 'archived' -- as long as it is no longer returned by the EntityBean(id) constructor.