com.sibvisions.rad.persist
Class AbstractStorage

java.lang.Object
  extended by com.sibvisions.rad.persist.AbstractStorage
All Implemented Interfaces:
ICloseable, IStorage, INamedObject
Direct Known Subclasses:
AbstractCachedStorage

public abstract class AbstractStorage
extends java.lang.Object
implements IStorage, INamedObject, ICloseable

The AbstractStorage implements the server side triggers mechanism for different types of Storages. It is the abstract base class for storages which needs a trigger mechanism.


Nested Class Summary
protected static class AbstractStorage.AllFetchedList<E>
          The AllFetchedList is an ArrayUtil wrapper that implements the marker interface IAllFetched.
 
Constructor Summary
AbstractStorage()
           
 
Method Summary
protected  IBean createBean(java.lang.Object[] pValues)
          Creates a bean with given values.
protected  BeanType createBeanType(java.lang.String[] pColumnNames)
          Creates a BeanType for the given column names.
 IFileHandle createCSV(java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort)
          Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle.
 IFileHandle createCSV(java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pLanguage)
          Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle.
 IFileHandle createCSV(java.lang.String pFileName, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort)
          Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle.
 IBean createEmptyBean()
          Creates a new bean with all column names from the meta data.
<T> T
createPOJO(java.lang.Class<T> pClass, IBean pBean)
          Creates a POJO from the given type and with the values from a bean.
protected
<T> T
createPOJO(java.lang.Class<T> pClass, java.lang.Object[] pValues)
          Creates a POJO from the given type and with given values.
protected  void debug(java.lang.Object... pInfo)
          Logs debug information.
 void delete(java.lang.Object[] pDeleteDataRow)
          Deletes the specified row from the storage.
<T> void
delete(T pObject)
          Deletes the specified bean/POJO from the storage.
protected  void error(java.lang.Object... pInfo)
          Logs error information.
 StorageHandler eventAfterDelete()
          Gets the EventHandler for after delete event.
 StorageHandler eventAfterInsert()
          Gets the EventHandler for after insert event.
 StorageHandler eventAfterUpdate()
          Gets the EventHandler for after update event.
 StorageHandler eventBeforeDelete()
          Gets the EventHandler for before delete event.
 StorageHandler eventBeforeInsert()
          Gets the EventHandler for before insert event.
 StorageHandler eventBeforeUpdate()
          Gets the EventHandler for before update event.
 StorageHandler eventCalculateRow()
          Gets the EventHandler for calculate row event.
 StorageHandler eventInsteadOfDelete()
          Gets the EventHandler for instead-of delete event.
 StorageHandler eventInsteadOfInsert()
          Gets the EventHandler for instead-of insert event.
 StorageHandler eventInsteadOfUpdate()
          Gets the EventHandler for instead-of update event.
protected abstract  void executeDelete(java.lang.Object[] pDeleteDataRow)
          This method has to be implemented in the Storage implementation and should have the functionality of the delete method.
protected  void executeDeleteAsBean(java.lang.Object[] pDeleteDataRow)
          This method will be used if delete(Object) was called.
protected abstract  java.util.List<java.lang.Object[]> executeFetch(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount)
          This method has to be implemented in the Storage implementation and should have the functionality of the fetch method.
protected  java.util.List<java.lang.Object[]> executeFetchAsBean(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount)
          This method will be used if fetchBean(ICondition, SortDefinition, int, int) was called.
protected abstract  java.lang.Object[] executeInsert(java.lang.Object[] pDataRow)
          This method has to be implemented in the Storage implementation and should have the functionality of the insert method.
protected  java.lang.Object[] executeInsertAsBean(java.lang.Object[] pDataRow)
          This method will be used if insert(Object) was called.
protected abstract  java.lang.Object[] executeRefetchRow(java.lang.Object[] pDataRow)
          This method has to be implemented in the Storage implementation and should have the functionality of the refetchRow method.
protected  java.lang.Object[] executeRefetchRowAsBean(java.lang.Object[] pDataRow)
          This method will be used if refetch(Object) was called.
protected abstract  java.lang.Object[] executeUpdate(java.lang.Object[] pOldDataRow, java.lang.Object[] pNewDataRow)
          This method has to be implemented in the Storage implementation and should have the functionality of the update method.
protected  java.lang.Object[] executeUpdateAsBean(java.lang.Object[] pOldDataRow, java.lang.Object[] pNewDataRow)
          This method will be used if update(Object) was called.
<T> T
fetch(java.lang.Class<T> pClass, ICondition pFilter)
          Returns the requested bean/POJO from the storage.
<T> java.util.List<T>
fetch(java.lang.Class<T> pClass, ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount)
          Returns the requested list of beans/POJOs from the storage.
 java.util.List<java.lang.Object[]> fetch(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount)
          Returns the requested rows as List[Object[]].
 IBean fetchBean(ICondition pFilter)
          Returns the requested bean from the storage.
 java.util.List<IBean> fetchBean(ICondition pFilter, SortDefinition pSort, int pFromRow, int pMinimumRowCount)
          Returns the requested list of beans from the storage.
protected  IBeanType getAndInitBeanType()
          Gets the bean type based on the meta data.
 BeanConverter getBeanConverter()
          Gets the BeanConverter for this storage and also initializes it with the metadata from this storage.
 java.lang.String getName()
          Gets the storage name.
 java.lang.String getPropertyNameForColumn(java.lang.String pColumnName)
          Gets the property name (Java standard) for the given column name.
protected  boolean hasInsteadOfDeleteEventHandler()
          Gets whether an insteadOf delete event was assigned.
protected  boolean hasInsteadOfInsertEventHandler()
          Gets whether an insteadOf insert event was assigned.
protected  boolean hasInsteadOfUpdateEventHandler()
          Gets whether an insteadOf update event was assigned.
protected  void info(java.lang.Object... pInfo)
          Logs information.
 java.lang.Object[] insert(java.lang.Object[] pDataRow)
          Returns the newly inserted row for this IStorage.
<T> T
insert(T pObject)
          Inserts the new bean/POJO and returns a bean/POJO with current values from the storage.
protected  boolean isLogEnabled(ILogger.LogLevel pLevel)
          Gets whether the given log level is enabled.
 boolean isRefetch()
          Returns if this Storage refetches after insert and update.
<T> T
refetch(T pObject)
          Refetches the specified bean/POJO and returns a bean/POJO with current values from the storage.
 java.lang.Object[] refetchRow(java.lang.Object[] pDataRow)
          It refetchs the specified row and returns it as Object[] from the storage.
 void setName(java.lang.String pName)
          Sets the storage name.
 void setPropertyNameForColumn(java.lang.String pColumnName, java.lang.String pPropertyName)
          Sets the property name (Java standard) for a given column name.
 void setRefetch(boolean pRefetch)
          Sets if this Storage refetches after insert and update.
 java.lang.Object[] update(java.lang.Object[] pOldDataRow, java.lang.Object[] pNewDataRow)
          Return the updated row as Object[].
<T> T
update(T pObject)
          Updates a bean/POJO with the PrimaryKey columns and provides values.
<T> T
update(T pOldObject, T pNewObject)
          Updates a bean/POJO with the PrimaryKey columns and provides values.
abstract  void writeCSV(java.io.OutputStream pStream, java.lang.String[] pColumnNames, java.lang.String[] pLabels, ICondition pFilter, SortDefinition pSort, java.lang.String pSeparator)
          Write the current storage with the specified filter and sort into the given output stream as CSV Format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.rad.persist.IStorage
getEstimatedRowCount, getMetaData
 
Methods inherited from interface com.sibvisions.util.ICloseable
close
 

Constructor Detail

AbstractStorage

public AbstractStorage()
Method Detail

fetch

public final java.util.List<java.lang.Object[]> fetch(ICondition pFilter,
                                                      SortDefinition pSort,
                                                      int pFromRow,
                                                      int pMinimumRowCount)
                                               throws DataSourceException
Returns the requested rows as List[Object[]]. Optimization can also return more then the minimum row count. If possible all in a certain time.

Specified by:
fetch in interface IStorage
Parameters:
pFilter - the ICondition to use.
pSort - the SortDefinition to use.
pFromRow - the from row index to request from storage.
pMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
Returns:
the requested rows as List[Object[]].
Throws:
DataSourceException - if an Exception occur during interacting with the storage.

refetchRow

public final java.lang.Object[] refetchRow(java.lang.Object[] pDataRow)
                                    throws DataSourceException
It refetchs the specified row and returns it as Object[] from the storage.
Before the user starts editing in the GUI, the IDataRow in the storage should be locked for updates.

Specified by:
refetchRow in interface IStorage
Parameters:
pDataRow - the specified row as Object[].
Returns:
the refetched row as Object[].
Throws:
DataSourceException - if an Exception occur during interacting with the storage.

insert

public final java.lang.Object[] insert(java.lang.Object[] pDataRow)
                                throws DataSourceException
Returns the newly inserted row for this IStorage.

Specified by:
insert in interface IStorage
Parameters:
pDataRow - the new row as Object[] to insert.
Returns:
the newly inserted row from this IStorage.
Throws:
DataSourceException - if an Exception occur during insert the row to the storage

update

public final java.lang.Object[] update(java.lang.Object[] pOldDataRow,
                                       java.lang.Object[] pNewDataRow)
                                throws DataSourceException
Return the updated row as Object[].

Specified by:
update in interface IStorage
Parameters:
pOldDataRow - the old row as Object[]
pNewDataRow - the new row as Object[] to update
Returns:
the updated row as Object[].
Throws:
DataSourceException - if an Exception occur during updating the row.

delete

public final void delete(java.lang.Object[] pDeleteDataRow)
                  throws DataSourceException
Deletes the specified row from the storage.

Specified by:
delete in interface IStorage
Parameters:
pDeleteDataRow - the row as Object[] to delete.
Throws:
DataSourceException - if an Exception occur during deleting the row or if the storage isn't opened or the PrimaryKey is wrong and more/less then one row is deleted.

writeCSV

public abstract void writeCSV(java.io.OutputStream pStream,
                              java.lang.String[] pColumnNames,
                              java.lang.String[] pLabels,
                              ICondition pFilter,
                              SortDefinition pSort,
                              java.lang.String pSeparator)
                       throws java.lang.Exception
Write the current storage with the specified filter and sort into the given output stream as CSV Format.

Parameters:
pStream - the output stream to use for the CSV stream
pColumnNames - the column names to include in the export
pLabels - the labels to show as header in the export
pFilter - the condition
pSort - the sort definition
pSeparator - the column separator
Throws:
java.lang.Exception - if the CSV output couldn't written to stream

executeRefetchRow

protected abstract java.lang.Object[] executeRefetchRow(java.lang.Object[] pDataRow)
                                                 throws DataSourceException
This method has to be implemented in the Storage implementation and should have the functionality of the refetchRow method.

Parameters:
pDataRow - the specified row as Object[].
Returns:
the refetched row as Object[].
Throws:
DataSourceException - if an Exception occur during interacting with the storage.
See Also:
IStorage.refetchRow(Object[])

executeFetch

protected abstract java.util.List<java.lang.Object[]> executeFetch(ICondition pFilter,
                                                                   SortDefinition pSort,
                                                                   int pFromRow,
                                                                   int pMinimumRowCount)
                                                            throws DataSourceException
This method has to be implemented in the Storage implementation and should have the functionality of the fetch method.

Parameters:
pFilter - the ICondition to use.
pSort - the SortDefinition to use.
pFromRow - the from row index to request from storage.
pMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
Returns:
the requested rows as List[Object[]].
Throws:
DataSourceException - if an Exception occur during interacting with the storage.
See Also:
IStorage.fetch(ICondition, SortDefinition, int, int)

executeInsert

protected abstract java.lang.Object[] executeInsert(java.lang.Object[] pDataRow)
                                             throws DataSourceException
This method has to be implemented in the Storage implementation and should have the functionality of the insert method.

Parameters:
pDataRow - the new row as Object[] to insert.
Returns:
the newly inserted row from this IStorage. null if no insert operation was performed.
Throws:
DataSourceException - if an Exception occur during insert the row to the storage
See Also:
IStorage.insert(Object[])

executeUpdate

protected abstract java.lang.Object[] executeUpdate(java.lang.Object[] pOldDataRow,
                                                    java.lang.Object[] pNewDataRow)
                                             throws DataSourceException
This method has to be implemented in the Storage implementation and should have the functionality of the update method.

Parameters:
pOldDataRow - the old row as Object[]
pNewDataRow - the new row as Object[] to update
Returns:
the updated row as Object[]. null if no update operation was performed.
Throws:
DataSourceException - if an Exception occur during updating the row.
See Also:
IStorage.update(Object[], Object[])

executeDelete

protected abstract void executeDelete(java.lang.Object[] pDeleteDataRow)
                               throws DataSourceException
This method has to be implemented in the Storage implementation and should have the functionality of the delete method.

Parameters:
pDeleteDataRow - the row as Object[] to delete.
Throws:
DataSourceException - if an Exception occur during deleting the row or if the storage isn't opened or the PrimaryKey is wrong and more/less then one row is deleted.
See Also:
IStorage.delete(Object[])

getBeanConverter

public BeanConverter getBeanConverter()
                               throws DataSourceException
Gets the BeanConverter for this storage and also initializes it with the metadata from this storage.

Returns:
the BeanConverter.
Throws:
DataSourceException - if initializing the BeanConverter with the metadata failed.

setName

public void setName(java.lang.String pName)
Sets the storage name.

Specified by:
setName in interface INamedObject
Parameters:
pName - the name

getName

public java.lang.String getName()
Gets the storage name.

Specified by:
getName in interface INamedObject
Returns:
the name

isRefetch

public boolean isRefetch()
Returns if this Storage refetches after insert and update.

Returns:
if this Storage refetches after insert and update.

setRefetch

public void setRefetch(boolean pRefetch)
Sets if this Storage refetches after insert and update.

Parameters:
pRefetch - true if this Storage refetches after insert and update.

isLogEnabled

protected boolean isLogEnabled(ILogger.LogLevel pLevel)
Gets whether the given log level is enabled.

Parameters:
pLevel - the level to check
Returns:
true if the log level is enabled, false otherwise

debug

protected void debug(java.lang.Object... pInfo)
Logs debug information.

Parameters:
pInfo - the debug information

info

protected void info(java.lang.Object... pInfo)
Logs information.

Parameters:
pInfo - the information

error

protected void error(java.lang.Object... pInfo)
Logs error information.

Parameters:
pInfo - the error information

createCSV

public IFileHandle createCSV(java.lang.String[] pColumnNames,
                             java.lang.String[] pLabels,
                             ICondition pFilter,
                             SortDefinition pSort)
                      throws java.lang.Exception
Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle. The filename will be built depending of the object name from the SessionContext.

Parameters:
pColumnNames - the column names to include in the export
pLabels - the labels to show as header in the export
pFilter - the filter to use on the DBStorage
pSort - the sort to use
Returns:
the file handle for the new generated CSV file.
Throws:
java.lang.Exception - if the CSV output couldn't written to stream.

createCSV

public IFileHandle createCSV(java.lang.String[] pColumnNames,
                             java.lang.String[] pLabels,
                             ICondition pFilter,
                             SortDefinition pSort,
                             java.lang.String pLanguage)
                      throws java.lang.Exception
Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle. The filename will be built depending of the object name from the SessionContext.

Parameters:
pColumnNames - the column names to include in the export
pLabels - the labels to show as header in the export
pFilter - the filter to use on the DBStorage
pSort - the sort to use
pLanguage - the language to use
Returns:
the file handle for the new generated CSV file.
Throws:
java.lang.Exception - if the CSV output couldn't written to stream.

createCSV

public IFileHandle createCSV(java.lang.String pFileName,
                             java.lang.String[] pColumnNames,
                             java.lang.String[] pLabels,
                             ICondition pFilter,
                             SortDefinition pSort)
                      throws java.lang.Exception
Write the current DBStorage with the specified filter and sort to the export.csv file in CSV format and returns the file handle.

Parameters:
pFileName - the filename to use.
pColumnNames - the column names to include in the export
pLabels - the labels to show as header in the export
pFilter - the filter to use on the DBStorage
pSort - the sort to use
Returns:
the file handle for the new generated CSV file.
Throws:
java.lang.Exception - if the CSV output couldn't written to stream.

eventCalculateRow

public StorageHandler eventCalculateRow()
Gets the EventHandler for calculate row event. This is called after fetch, refetchRow, insert and update method calls.

Returns:
the EventHandler for after deleted event.

eventInsteadOfInsert

public StorageHandler eventInsteadOfInsert()
Gets the EventHandler for instead-of insert event.

Returns:
the EventHandler for instead-of insert event.

eventBeforeInsert

public StorageHandler eventBeforeInsert()
Gets the EventHandler for before insert event.

Returns:
the EventHandler for before insert event.

eventAfterInsert

public StorageHandler eventAfterInsert()
Gets the EventHandler for after insert event.

Returns:
the EventHandler for after insert event.

eventInsteadOfUpdate

public StorageHandler eventInsteadOfUpdate()
Gets the EventHandler for instead-of update event.

Returns:
the EventHandler for instead-of update event.

eventBeforeUpdate

public StorageHandler eventBeforeUpdate()
Gets the EventHandler for before update event.

Returns:
the EventHandler for before update event.

eventAfterUpdate

public StorageHandler eventAfterUpdate()
Gets the EventHandler for after update event.

Returns:
the EventHandler for after update event.

eventInsteadOfDelete

public StorageHandler eventInsteadOfDelete()
Gets the EventHandler for instead-of delete event.

Returns:
the EventHandler for instead-of delete event.

eventBeforeDelete

public StorageHandler eventBeforeDelete()
Gets the EventHandler for before delete event.

Returns:
the EventHandler for before delete event.

eventAfterDelete

public StorageHandler eventAfterDelete()
Gets the EventHandler for after delete event.

Returns:
the EventHandler for after delete event.

hasInsteadOfInsertEventHandler

protected boolean hasInsteadOfInsertEventHandler()
Gets whether an insteadOf insert event was assigned.

Returns:
true if an insteadOf insert event was added, false otherwise

hasInsteadOfUpdateEventHandler

protected boolean hasInsteadOfUpdateEventHandler()
Gets whether an insteadOf update event was assigned.

Returns:
true if an insteadOf update event was added, false otherwise

hasInsteadOfDeleteEventHandler

protected boolean hasInsteadOfDeleteEventHandler()
Gets whether an insteadOf delete event was assigned.

Returns:
true if an insteadOf delete event was added, false otherwise

getAndInitBeanType

protected IBeanType getAndInitBeanType()
                                throws DataSourceException
Gets the bean type based on the meta data.

Returns:
the bean type
Throws:
DataSourceException - if an Exception occurs during interacting with the storage

createBeanType

protected BeanType createBeanType(java.lang.String[] pColumnNames)
Creates a BeanType for the given column names.

Parameters:
pColumnNames - the column names which are allowed for beans
Returns:
the bean type

createEmptyBean

public IBean createEmptyBean()
                      throws DataSourceException
Creates a new bean with all column names from the meta data. Only this column names are allowed.

Returns:
a new instance of an IBean implementation
Throws:
DataSourceException - if an Exception occurs during interacting with the storage

createBean

protected IBean createBean(java.lang.Object[] pValues)
                    throws DataSourceException
Creates a bean with given values. The bean contains the property names from the column meta data and not more.

Parameters:
pValues - the values in same order as the meta data
Returns:
a new bean
Throws:
DataSourceException - if an Exception occurs during interacting with the storage

createPOJO

protected <T> T createPOJO(java.lang.Class<T> pClass,
                           java.lang.Object[] pValues)
                throws DataSourceException
Creates a POJO from the given type and with given values.

Type Parameters:
T - the type of the POJO
Parameters:
pClass - the class of the POJO
pValues - the values for the properties in the same order as the meta data
Returns:
the POJO
Throws:
DataSourceException - if an Exception occurs during interacting with the storage

createPOJO

public <T> T createPOJO(java.lang.Class<T> pClass,
                        IBean pBean)
             throws DataSourceException
Creates a POJO from the given type and with the values from a bean.

Type Parameters:
T - the type of the POJO
Parameters:
pClass - the class of the POJO
pBean - the bean with values for the POJO
Returns:
the POJO
Throws:
DataSourceException - if an Exception occurs during interacting with the storage

setPropertyNameForColumn

public void setPropertyNameForColumn(java.lang.String pColumnName,
                                     java.lang.String pPropertyName)
Sets the property name (Java standard) for a given column name. The name will be used for synchronizing POJOs with beans.

Parameters:
pColumnName - the column name
pPropertyName - the java property name e.g. firstName instead of FIRST_NAME

getPropertyNameForColumn

public java.lang.String getPropertyNameForColumn(java.lang.String pColumnName)
Gets the property name (Java standard) for the given column name.

Parameters:
pColumnName - the column name e.g. FIRST_NAME
Returns:
the java property name e.g. firstName instead of FIRST_NAME

fetchBean

public IBean fetchBean(ICondition pFilter)
                throws DataSourceException
Returns the requested bean from the storage.

Parameters:
pFilter - the filter as ICondition to get exactly one Bean.
Returns:
the requested row as IBean, or null if no row was found
Throws:
DataSourceException - if an Exception occurs during interacting with the storage or more than one Bean were found

fetch

public <T> T fetch(java.lang.Class<T> pClass,
                   ICondition pFilter)
        throws DataSourceException
Returns the requested bean/POJO from the storage.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pClass - the class of the POJO or bean.
pFilter - the filter as ICondition to use get exactly one Bean.
Returns:
the requested Bean/POJO, or null if no Bean/POJO was found
Throws:
DataSourceException - if an Exception occur during interacting with the storage or more than one Bean/POJO were found

fetchBean

public java.util.List<IBean> fetchBean(ICondition pFilter,
                                       SortDefinition pSort,
                                       int pFromRow,
                                       int pMinimumRowCount)
                                throws DataSourceException
Returns the requested list of beans from the storage. It uses the filter to reduce the result, and the sort for the order.

Parameters:
pFilter - the filter as ICondition to use
pSort - the SortDefinition to use
pFromRow - the from row index to request from storage
pMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
Returns:
the requested list of Beans from the storage.
Throws:
DataSourceException - if an Exception occur during interacting with the storage.

fetch

public <T> java.util.List<T> fetch(java.lang.Class<T> pClass,
                                   ICondition pFilter,
                                   SortDefinition pSort,
                                   int pFromRow,
                                   int pMinimumRowCount)
                        throws DataSourceException
Returns the requested list of beans/POJOs from the storage. It uses the filter to reduce the result, and the sort for the order.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pClass - the class of the POJO or bean.
pFilter - the filter as ICondition to use
pSort - the SortDefinition to use
pFromRow - the from row index to request from storage
pMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
Returns:
the requested list of Beans/POJOs from the storage.
Throws:
DataSourceException - if an Exception occur during interacting with the storage.

refetch

public <T> T refetch(T pObject)
          throws DataSourceException
Refetches the specified bean/POJO and returns a bean/POJO with current values from the storage.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pObject - the specified bean/POJO to refetch from the storage.
Returns:
the refetched bean/POJO with all values from the storage.
Throws:
DataSourceException - if an Exception occur during interacting with the Storage.

insert

public <T> T insert(T pObject)
         throws DataSourceException
Inserts the new bean/POJO and returns a bean/POJO with current values from the storage.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pObject - the new IBean/POJO to insert to the storage.
Returns:
the newly inserted IBean/POJO with all automatically filled in values from the storage.
Throws:
DataSourceException - if an Exception occur during insert into the storage

update

public <T> T update(T pObject)
         throws DataSourceException
Updates a bean/POJO with the PrimaryKey columns and provides values. It returns a bean/POJO with the current values from the storage.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pObject - the new IBean/POJO to use for the update
Returns:
the updated IBean/POJO from the storage.
Throws:
DataSourceException - if an Exception occur during updating process in the storage.

update

public <T> T update(T pOldObject,
                    T pNewObject)
         throws DataSourceException
Updates a bean/POJO with the PrimaryKey columns and provides values. It returns a bean/POJO with the current values from the storage.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pOldObject - the old IBean/POJO to use for the update
pNewObject - the new IBean/POJO to use for the update
Returns:
the updated IBean/POJO from the storage.
Throws:
DataSourceException - if an Exception occur during updating process in the storage.

delete

public <T> void delete(T pObject)
            throws DataSourceException
Deletes the specified bean/POJO from the storage.

Type Parameters:
T - the type of the POJO or bean.
Parameters:
pObject - the bean/POJO to delete from the storage.
Throws:
DataSourceException - if an Exception occur during the delete operation in the storage.

executeRefetchRowAsBean

protected java.lang.Object[] executeRefetchRowAsBean(java.lang.Object[] pDataRow)
                                              throws DataSourceException
This method will be used if refetch(Object) was called.

Parameters:
pDataRow - the specified row as Object[].
Returns:
the refetched row as Object[].
Throws:
DataSourceException - if an Exception occur during interacting with the storage.
See Also:
IStorage.refetchRow(Object[])

executeFetchAsBean

protected java.util.List<java.lang.Object[]> executeFetchAsBean(ICondition pFilter,
                                                                SortDefinition pSort,
                                                                int pFromRow,
                                                                int pMinimumRowCount)
                                                         throws DataSourceException
This method will be used if fetchBean(ICondition, SortDefinition, int, int) was called.

Parameters:
pFilter - the ICondition to use.
pSort - the SortDefinition to use.
pFromRow - the from row index to request from storage.
pMinimumRowCount - the minimum row count to request, beginning from the pFromRow.
Returns:
the requested rows as List[Object[]].
Throws:
DataSourceException - if an Exception occur during interacting with the storage.
See Also:
IStorage.fetch(ICondition, SortDefinition, int, int)

executeInsertAsBean

protected java.lang.Object[] executeInsertAsBean(java.lang.Object[] pDataRow)
                                          throws DataSourceException
This method will be used if insert(Object) was called.

Parameters:
pDataRow - the new row as Object[] to insert.
Returns:
the newly inserted row from this IStorage.
Throws:
DataSourceException - if an Exception occur during insert the row to the storage
See Also:
IStorage.insert(Object[])

executeUpdateAsBean

protected java.lang.Object[] executeUpdateAsBean(java.lang.Object[] pOldDataRow,
                                                 java.lang.Object[] pNewDataRow)
                                          throws DataSourceException
This method will be used if update(Object) was called.

Parameters:
pOldDataRow - the old row as Object[]
pNewDataRow - the new row as Object[] to update
Returns:
the updated row as Object[].
Throws:
DataSourceException - if an Exception occur during updating the row.
See Also:
IStorage.update(Object[], Object[])

executeDeleteAsBean

protected void executeDeleteAsBean(java.lang.Object[] pDeleteDataRow)
                            throws DataSourceException
This method will be used if delete(Object) was called.

Parameters:
pDeleteDataRow - the row as Object[] to delete.
Throws:
DataSourceException - if an Exception occur during deleting the row or if the storage isn't opened or the PrimaryKey is wrong and more/less then one row is deleted.
See Also:
IStorage.delete(Object[])


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.