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.util.logging.Logger;
020    
021    /**
022     * Model a DELETE Statement
023     *
024     * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
025     * @version $Id: SqlDeleteByPkStatement.java,v 1.1 2007-08-24 22:17:39 ewestfal Exp $
026     */
027    public class SqlDeleteByPkStatement extends SqlPkStatement
028    {
029        private String sql;
030    
031        /**
032         * Constructor for SqlDeleteByPkStatement.
033         *
034         * @param cld
035         * @param logger
036         */
037        public SqlDeleteByPkStatement(ClassDescriptor cld, Logger logger)
038        {
039            super(cld, logger);
040        }
041    
042        /** @see SqlStatement#getStatement() */
043        public String getStatement()
044        {
045            if(sql == null)
046            {
047                StringBuffer stmt = new StringBuffer(1024);
048                ClassDescriptor cld = getClassDescriptor();
049    
050                stmt.append("DELETE FROM ");
051                appendTable(cld, stmt);
052                appendWhereClause(cld, true, stmt); //use Locking
053    
054                sql = stmt.toString();
055            }
056            return sql;
057        }
058    
059    }
060