JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource.jdbc
Class Persistor

java.lang.Object
  |
  +--com.klg.jclass.datasource.jdbc.Persistor
All Implemented Interfaces:
PersistorModel, Serializable

public class Persistor
extends Object
implements PersistorModel, Serializable

Default mechanism for persisting (resolving) data to the originating database.

See Also:
Serialized Form

Field Summary
protected static int ONE_ROW_CHANGED
           
protected  PreparedStatement update_statement
           
 
Constructor Summary
Persistor()
           
 
Method Summary
protected  void buildDeleteStatement(String table, Vector columns, Object[] original_row, com.klg.jclass.datasource.jdbc.MetaData metaData, com.klg.jclass.datasource.jdbc.DataTable dataTable)
          Builds the delete statement for a table.
protected  void buildUpdateStatement(String table, Vector columns, long bookmark, com.klg.jclass.datasource.jdbc.MetaData metaData, com.klg.jclass.datasource.jdbc.DataTable dataTable)
          Default method for building update statement.
protected  void commit(com.klg.jclass.datasource.jdbc.MetaData metaData)
          For internal use only.
protected  int executeUpdate(com.klg.jclass.datasource.jdbc.MetaData metaData)
          Commits the update to the database.
protected  String getQualifiedTableName(String table, boolean includeAlias, com.klg.jclass.datasource.jdbc.MetaData metaData)
          Return the qualified version of the table name, i.e., can be [catalog.][schema.]table [alias]
 void saveRow(long bookmark, com.klg.jclass.datasource.jdbc.MetaData metaDataModel, com.klg.jclass.datasource.DataTableModel dataTableModel)
          Persist the changes to the row to the originating data base and tables.
protected  void setUpdateParameter(int number, Object value, String col_id, com.klg.jclass.datasource.jdbc.MetaData metaData)
          Sets a particular parameter in the SQL update statement.
protected  void setUpdateStatement(String update, com.klg.jclass.datasource.jdbc.MetaData metaData)
          Sets the SQL statement to update data.
protected  boolean tablesColumnsModified(long bookmark, Vector columns, com.klg.jclass.datasource.jdbc.MetaData metaData, com.klg.jclass.datasource.jdbc.DataTable dataTable)
          Returns true if at least one of this table's columns been modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE_ROW_CHANGED

protected static final int ONE_ROW_CHANGED
See Also:
Constant Field Values

update_statement

protected transient PreparedStatement update_statement
Constructor Detail

Persistor

public Persistor()
Method Detail

saveRow

public void saveRow(long bookmark,
                    com.klg.jclass.datasource.jdbc.MetaData metaDataModel,
                    com.klg.jclass.datasource.DataTableModel dataTableModel)
             throws DataModelException
Description copied from interface: PersistorModel
Persist the changes to the row to the originating data base and tables.

Specified by:
saveRow in interface PersistorModel
Throws:
DataModelException - If any exception occurs.

commit

protected void commit(com.klg.jclass.datasource.jdbc.MetaData metaData)
               throws DataModelException
For internal use only. Call DataTableModel.commitRow(..) or DataModel.updateAll() instead. Actually commits this row to the server. Called by commitRow.

Throws:
DataModelException - If commit fails.

tablesColumnsModified

protected boolean tablesColumnsModified(long bookmark,
                                        Vector columns,
                                        com.klg.jclass.datasource.jdbc.MetaData metaData,
                                        com.klg.jclass.datasource.jdbc.DataTable dataTable)
                                 throws DataModelException
Returns true if at least one of this table's columns been modified.

Parameters:
bookmark - a long which uniquely identifies a row
columns - a Vector of indexes for this table's columns
Returns:
boolean, true if one or more columns were modified
DataModelException

buildDeleteStatement

protected void buildDeleteStatement(String table,
                                    Vector columns,
                                    Object[] original_row,
                                    com.klg.jclass.datasource.jdbc.MetaData metaData,
                                    com.klg.jclass.datasource.jdbc.DataTable dataTable)
                             throws DataModelException
Builds the delete statement for a table.

Parameters:
table - a String name for the table
columns - a Vector of column indexes
Throws:
DataModelException - If creation of delete statement fails.

buildUpdateStatement

protected void buildUpdateStatement(String table,
                                    Vector columns,
                                    long bookmark,
                                    com.klg.jclass.datasource.jdbc.MetaData metaData,
                                    com.klg.jclass.datasource.jdbc.DataTable dataTable)
                             throws DataModelException
Default method for building update statement. Loops on columns and builds a PreparedStatement.

Throws:
DataModelException - If build fails.

getQualifiedTableName

protected String getQualifiedTableName(String table,
                                       boolean includeAlias,
                                       com.klg.jclass.datasource.jdbc.MetaData metaData)
Return the qualified version of the table name, i.e., can be [catalog.][schema.]table [alias]


setUpdateStatement

protected void setUpdateStatement(String update,
                                  com.klg.jclass.datasource.jdbc.MetaData metaData)
                           throws DataModelException
Sets the SQL statement to update data. Statement can be sql statement or a stored procedure.

Throws:
DataModelException - If setUpdateStatement fails.

setUpdateParameter

protected void setUpdateParameter(int number,
                                  Object value,
                                  String col_id,
                                  com.klg.jclass.datasource.jdbc.MetaData metaData)
                           throws DataModelException
Sets a particular parameter in the SQL update statement. The update statement is automatically built.

Parameters:
number - an int indicating the position of the parameter
value - the Object which is to be set
col_id - column_name the column alias or column name as it appears in the select statement ([catalog.][schema.][table.]column)
Throws:
DataModelException - If setUpdatdParameter fails.

executeUpdate

protected int executeUpdate(com.klg.jclass.datasource.jdbc.MetaData metaData)
                     throws DataModelException
Commits the update to the database.

Returns:
rows_affected an int indicating the number of rows affected
Throws:
DataModelException - thrown if query fails

Copyright © 2004 Quest Software Inc..
All rights reserved.