com.stratelia.webactiv.persistence
Interface SilverpeasBeanDAO<T extends SilverpeasBeanIntf>

Type Parameters:
T -
All Known Implementing Classes:
SilverpeasBeanDAOImpl

public interface SilverpeasBeanDAO<T extends SilverpeasBeanIntf>

SilverpeasBeanDAO is the interface to use for instanciable component persistence. To get a SilverpeasBeanDAO instance, use the SilverpeasBeanDAO factory. A SilverpeasBeanDAO instance is linked with a SilverpeasBean specialisation. The code below show you how to build a SilverpeasBeanDAO, enable to create, update... objects for TrainingDetail class. // get a dao instance, associated with TrainingDetail bean class SilverpeasBeanDAO dao = SilverpeasBeanDAOFactory.getDAO("com.stratelia.webactiv.training.model.TrainingDetail"); Once a dao instance is build, it enables you to create, update, remove and list objects from TrainingDetail. TrainingDetail has to be a SilverpeasBean specialisation. (A SilverpeasBean contains a PK). The persistance mechanism is based on your bean properties. In your bean, you need to have getXXX and setXXX methods for each "column" you want to be persistant. For the moment, SilverpeasBeanDAO is able to work with int, String and Date. This list can grow in the near futur.


Field Summary
static int CONNECTION_TYPE_DATASOURCE
           
static int CONNECTION_TYPE_DATASOURCE_SILVERPEAS
           
static int CONNECTION_TYPE_EJBDATASOURCE_SILVERPEAS
           
static int CONNECTION_TYPE_JDBC_CLASSIC
           
 
Method Summary
 WAPrimaryKey add(Connection con, T bean)
           
 WAPrimaryKey add(T bean)
          create the bean and a row in DB.
 T findByPrimaryKey(Connection con, WAPrimaryKey pk)
           
 T findByPrimaryKey(WAPrimaryKey pk)
          get a bean representing a row in db from its pk
 Collection<T> findByWhereClause(Connection con, WAPrimaryKey pk, String whereClause)
           
 Collection<T> findByWhereClause(WAPrimaryKey pk, String whereClause)
          get a bean list, representing a specific row selection.
 void remove(Connection con, WAPrimaryKey pk)
           
 void remove(WAPrimaryKey pk)
          remove the row in db represented by the primary key.
 void removeWhere(Connection con, WAPrimaryKey pk, String p_WhereClause)
           
 void removeWhere(WAPrimaryKey pk, String p_WhereClause)
          remove all row in db represented by the where clause.
 void update(Connection con, T bean)
           
 void update(T bean)
          update the row in db with the new bean properties.
 

Field Detail

CONNECTION_TYPE_EJBDATASOURCE_SILVERPEAS

static final int CONNECTION_TYPE_EJBDATASOURCE_SILVERPEAS
See Also:
Constant Field Values

CONNECTION_TYPE_DATASOURCE_SILVERPEAS

static final int CONNECTION_TYPE_DATASOURCE_SILVERPEAS
See Also:
Constant Field Values

CONNECTION_TYPE_DATASOURCE

static final int CONNECTION_TYPE_DATASOURCE
See Also:
Constant Field Values

CONNECTION_TYPE_JDBC_CLASSIC

static final int CONNECTION_TYPE_JDBC_CLASSIC
See Also:
Constant Field Values
Method Detail

update

void update(T bean)
            throws PersistenceException
update the row in db with the new bean properties.

Parameters:
bean - the SilverpeasBean to update, with its complete primaryKey.
Throws:
PersistenceException

update

void update(Connection con,
            T bean)
            throws PersistenceException
Throws:
PersistenceException

add

WAPrimaryKey add(T bean)
                 throws PersistenceException
create the bean and a row in DB.

Parameters:
bean - the SilverpeasBeanIntf to update, with a primaryKey initialized with only spaceId and componentId.
Returns:
The complete primary key, with the id.
Throws:
PersistenceException

add

WAPrimaryKey add(Connection con,
                 T bean)
                 throws PersistenceException
Throws:
PersistenceException

remove

void remove(WAPrimaryKey pk)
            throws PersistenceException
remove the row in db represented by the primary key.

Parameters:
bean - the SilverpeasBeanIntf to update, with a primaryKey initialized with only spaceId and componentId.
Throws:
PersistenceException

remove

void remove(Connection con,
            WAPrimaryKey pk)
            throws PersistenceException
Throws:
PersistenceException

removeWhere

void removeWhere(WAPrimaryKey pk,
                 String p_WhereClause)
                 throws PersistenceException
remove all row in db represented by the where clause.

Parameters:
the - where clause.
Throws:
PersistenceException

removeWhere

void removeWhere(Connection con,
                 WAPrimaryKey pk,
                 String p_WhereClause)
                 throws PersistenceException
Throws:
PersistenceException

findByWhereClause

Collection<T> findByWhereClause(WAPrimaryKey pk,
                                String whereClause)
                                                           throws PersistenceException
get a bean list, representing a specific row selection.

Parameters:
pk - the beans primary key initialized with at least spaceId and componentId.
whereClause - The where clause to put in select request. If null, all SilverpeasBeanIntfs will be selected (all rows in the table).
Returns:
The list of SilverpeasBeanIntfs corresponding to the where clause
Throws:
PersistenceException

findByWhereClause

Collection<T> findByWhereClause(Connection con,
                                WAPrimaryKey pk,
                                String whereClause)
                                                           throws PersistenceException
Throws:
PersistenceException

findByPrimaryKey

T findByPrimaryKey(WAPrimaryKey pk)
                                              throws PersistenceException
get a bean representing a row in db from its pk

Parameters:
pk - the complete beans primary key
Returns:
The SilverpeasBeanIntfs corresponding to the pk, null if not found
Throws:
PersistenceException

findByPrimaryKey

T findByPrimaryKey(Connection con,
                   WAPrimaryKey pk)
                                              throws PersistenceException
Throws:
PersistenceException


Copyright © 2016 Silverpeas. All Rights Reserved.