001    package org.apache.ojb.broker.accesslayer.sql;
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.metadata.ClassDescriptor;
019    import org.apache.ojb.broker.platforms.Platform;
020    import org.apache.ojb.broker.query.Query;
021    
022    /**
023     * This interface defines the behaviour of an SqlGenartor component 
024     * that is responsible for building sql statements.
025     *
026     * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
027     * @version $Id: SqlGenerator.java,v 1.1 2007-08-24 22:17:39 ewestfal Exp $
028     */
029    public interface SqlGenerator
030    {
031        /**
032        * generate an INSERT-Statement for M:N indirection table
033         *
034         * @param table
035         * @param pkColumns1
036         * @param pkColumns2
037         * @return String
038         */
039        public String getInsertMNStatement(String table, String[] pkColumns1, String[] pkColumns2);
040    
041        /**
042         * generate a SELECT-Statement for M:N indirection table
043         * @param table the indirection table
044         * @param selectColumns selected columns
045         * @param columns for where
046         */
047        public String getSelectMNStatement(String table, String[] selectColumns, String[] columns);
048    
049        /**
050         * generate a DELETE-Statement for M:N indirection table
051         *
052         * @param table
053         * @param pkColumns1
054         * @param pkColumns2
055         * @return String
056         */
057        public String getDeleteMNStatement(String table, String[] pkColumns1, String[] pkColumns2);
058    
059        /**
060         * generate a select-Statement according to query
061         * @param query the Query
062         * @param cld the ClassDescriptor
063         */
064        public SelectStatement getPreparedSelectStatement(Query query, ClassDescriptor cld);
065    
066        /**
067         * generate a select-Statement according to query
068         * @param query the Query
069         * @param cld the ClassDescriptor
070         */
071        public SelectStatement getSelectStatementDep(Query query, ClassDescriptor cld);
072    
073        /**
074         * generate a prepared DELETE-Statement according to query
075         * @param query the Query
076         * @param cld the ClassDescriptor
077         */
078        public SqlStatement getPreparedDeleteStatement(Query query, ClassDescriptor cld);
079        
080        /**
081         * generate a prepared DELETE-Statement for the Class
082         * described by cld.
083         * @param cld the ClassDescriptor
084         */
085        public SqlStatement getPreparedDeleteStatement(ClassDescriptor cld);
086        
087        /**
088         * generate a prepared INSERT-Statement for the Class
089         * described by mif.
090         * @param cld the ClassDescriptor
091         */
092        public SqlStatement getPreparedInsertStatement(ClassDescriptor cld);
093        
094        /**
095         * generate a prepared SELECT-Statement for the Class
096         * described by cld
097         * @param cld the ClassDescriptor
098         */
099        public SelectStatement getPreparedSelectByPkStatement(ClassDescriptor cld);
100    
101        /**
102         * generate a prepared UPDATE-Statement for the Class
103         * described by cld
104         * @param cld the ClassDescriptor
105         */
106        public SqlStatement getPreparedUpdateStatement(ClassDescriptor cld);
107    
108    
109        /**
110         * Answer the Platform used by the SqlGenerator
111         * @return Platform
112         */
113        public Platform getPlatform();
114    
115    }