org.jdbcpersistence
Interface JDBCConnection

All Superinterfaces:
java.sql.Connection, java.sql.Wrapper

public interface JDBCConnection
extends java.sql.Connection

The main interface of JDBCPersistence that provides methods to manipulate underlying object representations in a database.

 Example:
 
    JDBCConnection conn = jdbcPersistence.getConnection();
    User user = new UserImpl();
    user.setid("the-unique-id");
    user.setName('the-unique-name");
    user.setFirstName("John");
    user.setLastName("Doe");
    conn.insert(user);
 
 

Author:
Alex Rojkov Date: 21-Aug-2005 Time: 10:26:28 AM
See Also:
JDBCPersistence.getConnection(), JDBCQuery

Field Summary
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Method Summary
 int delete(java.lang.Object object)
          Deletes an object's representation in database.
 int[] delete(java.lang.Object[] batch)
          Deletes a batch of Objects from database.
 int[] executeBatchUpdate(JDBCQuery query, java.lang.Object[][] params)
          Executes batch update and returns a number of rows affected by the update
 java.util.List executeQuery(JDBCQuery query, java.lang.Object[] params, java.util.List result)
          Executes query and returns a List of results that might be a collection of beans or a collection of Maps as specified by the query object
 int executeUpdate(JDBCQuery query, java.lang.Object[] params)
          Executes update and returns a number of rows affected by the update
 int insert(java.lang.Object object)
          Inserts data encapsulated by a persistent object into database.
 int[] insert(java.lang.Object[] batch)
          Inserts a batch of Objects into database.
 java.lang.Object load(java.lang.Class clazz, java.lang.Object[] primaryKey)
          Loads object's representation from database, creates an instance of mapped object, sets it's fields and return the instance of mapped object.
 int update(java.lang.Object object)
          Updates an object's representation in database.
 int[] update(java.lang.Object[] batch)
          Updates a batch of Objects in database.
 
Methods inherited from interface java.sql.Connection
clearWarnings, close, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Method Detail

insert

int insert(java.lang.Object object)
           throws java.sql.SQLException
Inserts data encapsulated by a persistent object into database.

Parameters:
object - object encapsulating the data to be inserted
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain

insert

int[] insert(java.lang.Object[] batch)
             throws java.sql.SQLException,
                    java.sql.BatchUpdateException
Inserts a batch of Objects into database. Uses batch functionality provided by java.sql.PreparedStatement.

Parameters:
batch - array of Objects to insert
Returns:
an array of update counts containing one element for each object in the batch. The elements of the array are ordered according to the order in which objects appeared in the batch.
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain
java.sql.BatchUpdateException - any BatchUpdateException that should occur during the insert propogates up the call chain
See Also:
Statement.executeBatch()

update

int update(java.lang.Object object)
           throws java.sql.SQLException
Updates an object's representation in database.

Parameters:
object - object a representation of which to update
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain

update

int[] update(java.lang.Object[] batch)
             throws java.sql.SQLException,
                    java.sql.BatchUpdateException
Updates a batch of Objects in database. Uses batch functionality provided by java.sql.PreparedStatement.

Parameters:
batch - array of Objects to update
Returns:
an array of update counts containing one element for each object in the batch. The elements of the array are ordered according to the order in which objects appeared in the batch.
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain
java.sql.BatchUpdateException - any BatchUpdateException that should occur during the insert propogates up the call chain
See Also:
Statement.executeBatch()

delete

int delete(java.lang.Object object)
           throws java.sql.SQLException
Deletes an object's representation in database.

Parameters:
object - an object a representation of which to delete
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain

delete

int[] delete(java.lang.Object[] batch)
             throws java.sql.SQLException,
                    java.sql.BatchUpdateException
Deletes a batch of Objects from database. Uses batch functionality provided by java.sql.PreparedStatement.

Parameters:
batch - array of Objects to delete
Returns:
an array of update counts containing one element for each object in the batch. The elements of the array are ordered according to the order in which objects appeared in the batch.
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain
java.sql.BatchUpdateException - any BatchUpdateException that should occur during the insert propogates up the call chain
See Also:
Statement.executeBatch()

load

java.lang.Object load(java.lang.Class clazz,
                      java.lang.Object[] primaryKey)
                      throws java.sql.SQLException
Loads object's representation from database, creates an instance of mapped object, sets it's fields and return the instance of mapped object.

Parameters:
primaryKey - array of objects where each object represents a column of a primary key in the order of columns in primary key
Returns:
an instance of mapped bean with all the fields initialized with the values read from database or null if no such object was found
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain

executeQuery

java.util.List executeQuery(JDBCQuery query,
                            java.lang.Object[] params,
                            java.util.List result)
                            throws java.sql.SQLException
Executes query and returns a List of results that might be a collection of beans or a collection of Maps as specified by the query object

Parameters:
query - query that will be executed.
params - parameters to the query, should be given in the order in which they are specified in the query
result - an java.util.List object or null. If null is passed then an instance of an ArrayList will be created to hold the results.
Returns:
List of beans or Map objects.
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain
See Also:
JDBCQuery

executeUpdate

int executeUpdate(JDBCQuery query,
                  java.lang.Object[] params)
                  throws java.sql.SQLException
Executes update and returns a number of rows affected by the update

Parameters:
query - update that will be executed.
params - parameters to the update statement, should be given in the order in which they are specified in the statement
Returns:
List of beans or Map objects.
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain
See Also:
JDBCQuery

executeBatchUpdate

int[] executeBatchUpdate(JDBCQuery query,
                         java.lang.Object[][] params)
                         throws java.sql.SQLException,
                                java.sql.BatchUpdateException
Executes batch update and returns a number of rows affected by the update

Parameters:
query - org.jdbcpersistence.jdbcQuery object to execute.
params - an array of arrays of parameters to the jdbcQuery
Throws:
java.sql.SQLException - any SQLException that should occur during the insert propogates up the call chain
java.sql.BatchUpdateException - any BatchUpdateException that should occur during the insert propogates up the call chain
See Also:
Statement.executeBatch()