001: package org.apache.ojb.broker.accesslayer;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import java.sql.PreparedStatement;
019: import java.sql.ResultSet;
020: import java.sql.SQLException;
021: import java.sql.Statement;
022:
023: import org.apache.ojb.broker.Identity;
024: import org.apache.ojb.broker.PersistenceBrokerException;
025: import org.apache.ojb.broker.PersistenceBrokerSQLException;
026: import org.apache.ojb.broker.core.ValueContainer;
027: import org.apache.ojb.broker.metadata.ClassDescriptor;
028: import org.apache.ojb.broker.query.Query;
029:
030: /**
031: * @version $Id: StatementManagerIF.java,v 1.10.2.3 2005/12/21 22:22:58 tomdz Exp $
032: */
033: public interface StatementManagerIF {
034:
035: /** fetchSize hint marking that setting fetch size for current statement is N/A. */
036: int FETCH_SIZE_NOT_APPLICABLE = -1;
037: /** fetchSize hint marking that there is no statement-level explicit override. */
038: int FETCH_SIZE_NOT_EXPLICITLY_SET = 0;
039:
040: /**
041: * Binds the Identities Primary key values to the statement.
042: * @param stmt
043: * @param oid
044: * @param cld ClassDescriptor for the Object, if <i>null</i> will be lookup automatic
045: */
046: void bindDelete(PreparedStatement stmt, Identity oid,
047: ClassDescriptor cld) throws java.sql.SQLException;
048:
049: /**
050: * binds the objects primary key and locking values to the statement, BRJ
051: */
052: void bindDelete(PreparedStatement stmt, ClassDescriptor cld,
053: Object obj) throws java.sql.SQLException;
054:
055: /**
056: * bind a Query based Select Statement
057: */
058: int bindStatement(PreparedStatement stmt, Query query,
059: ClassDescriptor cld, int param) throws SQLException;
060:
061: /**
062: * binds the values of the object obj to the statements parameters
063: */
064: void bindInsert(PreparedStatement stmt, ClassDescriptor cld,
065: Object obj) throws SQLException;
066:
067: /**
068: * binds the Identities Primary key values to the statement
069: * @param stmt
070: * @param oid
071: * @param cld ClassDescriptor for the Object, if <i>null</i> will be lookup automatic
072: * @param callableStmt Indicate if the specified {@link java.sql.PreparedStatement}
073: * is a {@link java.sql.CallableStatement} supporting stored procedures.
074: */
075: void bindSelect(PreparedStatement stmt, Identity oid,
076: ClassDescriptor cld, boolean callableStmt)
077: throws SQLException;
078:
079: /**
080: * binds the values of the object obj to the statements parameters
081: */
082: void bindUpdate(PreparedStatement stmt, ClassDescriptor cld,
083: Object obj) throws SQLException;
084:
085: /**
086: * binds the given array of values (if not null) starting from the given
087: * parameter index
088: * @return the next parameter index
089: */
090: int bindValues(PreparedStatement stmt,
091: ValueContainer[] valueContainer, int index)
092: throws SQLException;
093:
094: /**
095: * return a prepared DELETE Statement fitting for the given ClassDescriptor
096: */
097: PreparedStatement getDeleteStatement(ClassDescriptor cds)
098: throws PersistenceBrokerSQLException;
099:
100: /**
101: * return a generic Statement for the given ClassDescriptor
102: */
103: Statement getGenericStatement(ClassDescriptor cds,
104: boolean scrollable) throws PersistenceBrokerException;
105:
106: /**
107: * return a prepared Insert Statement fitting for the given ClassDescriptor
108: */
109: PreparedStatement getInsertStatement(ClassDescriptor cds)
110: throws PersistenceBrokerSQLException;
111:
112: /**
113: * Return a PreparedStatement for selecting against the given ClassDescriptor.
114: */
115: PreparedStatement getPreparedStatement(ClassDescriptor cds,
116: String sql, boolean scrollable, int explicitFetchSizeHint,
117: boolean callableStmt) throws PersistenceBrokerException;
118:
119: /**
120: * return a prepared Select Statement for the given ClassDescriptor
121: */
122: PreparedStatement getSelectByPKStatement(ClassDescriptor cds)
123: throws PersistenceBrokerSQLException;
124:
125: /**
126: * return a prepared Update Statement fitting to the given ClassDescriptor
127: */
128: PreparedStatement getUpdateStatement(ClassDescriptor cds)
129: throws PersistenceBrokerSQLException;
130:
131: public void closeResources(Statement stmt, ResultSet rs);
132:
133: }
|