com.syrtsov.ddao.factory
Interface StatementFactory

All Known Implementing Classes:
DefaultStatementFactory

public interface StatementFactory

Created by Pavel Syrtsov Date: Nov 3, 2007 Time: 8:16:33 PM

StatementFactory interface defines ability of the object to: create prepared statment and bind all necessary parameters to it. When this factory object created framework will initialize it with method setup Then it will be used to create JDBC prepared statement and bind to it arguments data objects if any. To define what implementation class shall be used to construct statement for Dao use annotation UseStatementFactory


Method Summary
 java.sql.PreparedStatement createStatement(java.sql.Connection connection, java.lang.Object[] args)
          Creates new PreparedStatement according to definition given in setup.
 void init(java.lang.String sql, java.lang.reflect.Method method)
          Initializes factory object with query data
 

Method Detail

init

void init(java.lang.String sql,
          java.lang.reflect.Method method)
          throws StatementFactoryException
Initializes factory object with query data

Parameters:
sql - - query text
method - - method that quey will be attached to
Throws:
StatementFactoryException - - throws excpetion if fails to parse query

createStatement

java.sql.PreparedStatement createStatement(java.sql.Connection connection,
                                           java.lang.Object[] args)
                                           throws StatementFactoryException
Creates new PreparedStatement according to definition given in setup. This method implementation has to be thread safe.

Parameters:
connection - - JDBC connection to be used to create new statement
args - - parameters values to bind to prepared statement
Returns:
PreparedStatement instance ready to be executed
Throws:
StatementFactoryException - if it fails to create and initialize prepared statement