com.j_spaces.sadapter.GenericJDBC
Interface IComplexColumns


public interface IComplexColumns

IComplexColumns is an interface that can be used to handle complex columns as they are written to the SA. The default handling of complex columns in in SA is writting them as serialized objects + an additional column for the hashcode. Sometimes (when the entry records are directly visible to non-space implementations) it is desirable to write a complex column (for example- a collection) as child-records in another table. A string value can also be returned for each complex column and it will be stored in the entries table in an additional column (example: a collection can be stored as a comma-seperated string or a complex column can be stored as a key to another table)

Since:
3.0

Field Summary
static int CALLMODE_AFTER_OPERATION
           
static int CALLMODE_BEFORE_OPERATION
           
 
Method Summary
 void close()
          called when SA have shut down
 void deleteColumnValue(Connection Con, com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes colAttributes, String entryUid)
          called when an entry row is deleted from entries table (note - if complex column is only stored as an additional string in entry table- no operation is needed.
 String[] init(com.j_spaces.sadapter.GenericJDBC.JDBCStorageAdapter sa, String initParam, int initMode, com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes[] cCols, HashMap<Integer,String> m_SQLToDB, String containerName, String spaceName, com.j_spaces.sadapter.GenericJDBC.ConstantStatements m_constantstatements)
          Initializes this module, called when SA is initialized.
 String newColumnValue(Connection Con, com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes colAttributes, String EntryUid, Object columnValue, int callMode, boolean updateMode)
          called when a new row is inserted to the entries table if m_CColsHandlingMethod.m_EmbeddedColumnName field of the ComplexColumnAttributes is not null the method will be called before insert and is expected to return a string value that will be stored in the entries table .
 com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes newTableColumn(Connection Con, com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes colAttributes, int callMode)
           Called when a new type of entry is introduced to the SA and a table is created for it. this method might be called twice-before table creation (so it can return names of columns to be added for string value storing) and after table creation (to allow creation of child tables).
 

Field Detail

CALLMODE_BEFORE_OPERATION

static final int CALLMODE_BEFORE_OPERATION
See Also:
Constant Field Values

CALLMODE_AFTER_OPERATION

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

init

String[] init(com.j_spaces.sadapter.GenericJDBC.JDBCStorageAdapter sa,
              String initParam,
              int initMode,
              com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes[] cCols,
              HashMap<Integer,String> m_SQLToDB,
              String containerName,
              String spaceName,
              com.j_spaces.sadapter.GenericJDBC.ConstantStatements m_constantstatements)
              throws SQLException
Initializes this module, called when SA is initialized.

Parameters:
sa - JDBC storage adapter
initParam - parameter passed to the SA in its properties for the IComplexColumns usage (can be a url ) .
initMode - SA initialization mode (value from com.j_spaces.core.sadapter.StorageAdapterInitMode
cCols - for initMode = warm start, the list of currently handled complex columns
m_SQLToDB - (for readonly !) a hashmap that maps each java.sql.Types.xxxx sql type to the type name in the DB
containerName - name of the container for this space
spaceName - name of this space
Returns:
a array of strings, names of all the java classes for which complex column handling will be performed (if null returned - no complex columns calls will be made)
Throws:
SQLException

newTableColumn

com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes newTableColumn(Connection Con,
                                                                         com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes colAttributes,
                                                                         int callMode)
                                                                         throws SQLException
     Called when a new type of entry is introduced to the SA and a table is created for it. this method might be called twice-before table creation (so it can return names of columns to be added for string value storing) and after table creation (to allow creation of child tables).
  

Parameters:
Con - JDBC open connection, any operation should use it note! dont set autocommit and dont commit .
colAttributes - potential complex column attributes .
callMode - CALLMODE_AFTER_OPERATION or CALLMODE_BEFORE_OPERATION (before or after entries table creation see method returned value ).
Returns:
returned ComplexColumnAttributes that contains the m_CColsHandlingMethod object. If CColsHandlingMethod.m_ChildTables is true, this method will also be called after entries table creation in order to enable child tables creations with callMode = - if null is returned this column will not be treated as a complex-column
Throws:
SQLException

newColumnValue

String newColumnValue(Connection Con,
                      com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes colAttributes,
                      String EntryUid,
                      Object columnValue,
                      int callMode,
                      boolean updateMode)
                      throws SQLException
called when a new row is inserted to the entries table if m_CColsHandlingMethod.m_EmbeddedColumnName field of the ComplexColumnAttributes is not null the method will be called before insert and is expected to return a string value that will be stored in the entries table . if CColsHandlingMethod.m_ChildTables is true the method will be called after insert

Parameters:
Con - JDBC open connection, any operation should use it note! - dont set autocommit and dont commit .
colAttributes - complex column attributes .
EntryUid - unique id of entry (its primary key value).
columnValue - (non-null) value of complex column .
callMode - CALLMODE_AFTER_OPERATION or CALLMODE_BEFORE_OPERATION (before or after entries table row insert- see method returned value ).
updateMode - true if this is an update operation, so a value may already exist for the EntryUid.
Returns:
if m_CColsHandlingMethod.m_EmbeddedColumnName field of the ComplexColumnAttributes is not null the method will be called before insert and is expected to return a string value that will be stored in the entries table . if CColsHandlingMethod.m_ChildTables is true the method will be called after insert
Throws:
SQLException

deleteColumnValue

void deleteColumnValue(Connection Con,
                       com.j_spaces.sadapter.GenericJDBC.ComplexColumnAttributes colAttributes,
                       String entryUid)
                       throws SQLException
called when an entry row is deleted from entries table (note - if complex column is only stored as an additional string in entry table- no operation is needed. Also if child tables are using cascade-delete to entry record- no operation needed)

Parameters:
Con - JDBC open connection, any operation should use it note! - dont set autocommit and dont commit .
colAttributes - Column attribute.
entryUid - unique id of entry (its primary key value).
Throws:
SQLException

close

void close()
           throws SQLException
called when SA have shut down

Throws:
SQLException