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 org.apache.ojb.broker.Identity;
019    import org.apache.ojb.broker.PersistenceBrokerException;
020    import org.apache.ojb.broker.core.ValueContainer;
021    import org.apache.ojb.broker.metadata.ClassDescriptor;
022    import org.apache.ojb.broker.query.Query;
023    
024    /**
025     * JdbcAccess is responsible for establishing performing
026     * SQL Queries against remote Databases.
027     * It hides all knowledge about JDBC from the
028     * {@link org.apache.ojb.broker.PersistenceBroker}
029     *
030     * @author <a href="mailto:thma@apache.org">Thomas Mahler</a>
031     * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
032     * @version $Id: JdbcAccess.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
033     */
034    public interface JdbcAccess
035    {
036        /**
037         * performs a DELETE operation against RDBMS.
038         * @param cld ClassDescriptor providing mapping information.
039         * @param obj The object to be deleted.
040         */
041        public void executeDelete(ClassDescriptor cld, Object obj) throws PersistenceBrokerException;
042    
043        /**
044         * performs a DELETE operation based on the given {@link Query} against RDBMS.
045         * @param query the query string.
046         * @param cld ClassDescriptor providing JDBC information.
047         */
048        public void executeDelete(Query query, ClassDescriptor cld) throws PersistenceBrokerException;
049    
050        /**
051         * performs an INSERT operation against RDBMS.
052         * @param obj The Object to be inserted as a row of the underlying table.
053         * @param cld ClassDescriptor providing mapping information.
054         */
055        public void executeInsert(ClassDescriptor cld, Object obj) throws PersistenceBrokerException;
056    
057        /**
058         * performs a SQL SELECT statement against RDBMS.
059         * @param sqlStatement the query string.
060         * @param cld ClassDescriptor providing meta-information.
061             * @param scrollable Does this resultset need cursor control for operations like last, first and size
062         */
063        public ResultSetAndStatement executeSQL(String sqlStatement, ClassDescriptor cld, boolean scrollable) throws PersistenceBrokerException;
064    
065        /**
066         * performs a SQL SELECT statement against RDBMS.
067         * @param sqlStatement the query string.
068         * @param cld ClassDescriptor providing meta-information.
069         * @param values The set of values to bind to the statement (may be null)
070             * @param scrollable Does this resultset need cursor control for operations like last, first and size
071         */
072        public ResultSetAndStatement executeSQL(String sqlStatement, ClassDescriptor cld, ValueContainer[] values, boolean scrollable) throws PersistenceBrokerException;
073    
074        /**
075         * performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.
076         * @param sqlStatement the query string.
077         * @param cld ClassDescriptor providing meta-information.
078         * @return int returncode
079         */
080        public int executeUpdateSQL(String sqlStatement, ClassDescriptor cld)
081                throws PersistenceBrokerException;
082    
083        /**
084         * performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.
085         * @param sqlStatement the query string.
086         * @param cld ClassDescriptor providing meta-information.
087         * @param values1 The first set of values to bind to the statement (may be null)
088         * @param values2 The second set of values to bind to the statement (may be null)
089         * @return int returncode
090         */
091        public int executeUpdateSQL(String sqlStatement, ClassDescriptor cld, ValueContainer[] values1, ValueContainer[] values2)
092                throws PersistenceBrokerException;
093        /**
094         * performs an UPDATE operation against RDBMS.
095         * @param obj The Object to be updated in the underlying table.
096         * @param cld ClassDescriptor providing mapping information.
097         */
098        public void executeUpdate(ClassDescriptor cld, Object obj) throws PersistenceBrokerException;
099    
100        /**
101         * performs a primary key lookup operation against RDBMS and materializes
102         * an object from the resulting row. Only skalar attributes are filled from
103         * the row, references are not resolved.
104         * @param oid contains the primary key info.
105         * @param cld ClassDescriptor providing mapping information.
106         * @return the materialized object, null if no matching row was found or if
107         * any error occured.
108         */
109        public Object materializeObject(ClassDescriptor cld, Identity oid)
110                throws PersistenceBrokerException;
111    
112        /**
113         * performs a SELECT operation against RDBMS.
114         * @param query the query string.
115         * @param cld ClassDescriptor providing JDBC information.
116         */
117        public ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException;
118    }