001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.core.framework.persistence.ojb; 017 018import org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement; 019import org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement; 020import org.apache.ojb.broker.metadata.ClassDescriptor; 021import org.apache.ojb.broker.platforms.Platform; 022import org.apache.ojb.broker.query.Query; 023import org.apache.ojb.broker.util.logging.Logger; 024 025/** 026 * A SqlSelectStatement sublclass that is aware of a special {@link SuffixableQueryByCriteria} Criteria 027 * class and will append a suffix specified by that class of criteria to the generated SQL statement. 028 * This is a hack to introduce select-for-update functionality into OJB so the same ORM/Criteria abstractions 029 * can be retained for select-for-update queries. Select for update appears to have been added in the OJB 030 * source repository, so maybe a forthcoming release will include this functionality and these kludges can be 031 * removed. 032 * @see SqlGeneratorSuffixableImpl 033 * @see SuffixableQueryByCriteria 034 * @author Kuali Rice Team (rice.collab@kuali.org) 035 */ 036@Deprecated 037public class SuffixedSqlSelectStatement extends SqlSelectStatement { 038 039 public SuffixedSqlSelectStatement(Platform pf, ClassDescriptor cld, Query query, Logger logger) { 040 super(pf, cld, query, logger); 041 } 042 043 public SuffixedSqlSelectStatement(SqlQueryStatement parent, Platform pf, ClassDescriptor cld, Query query, 044 Logger logger) { 045 super(parent, pf, cld, query, logger); 046 } 047 048 @Override 049 protected String buildStatement() { 050 String stmt = super.buildStatement(); 051 Query query = this.getQuery(); 052 if (query instanceof SuffixableQueryByCriteria) { 053 stmt += " " + ((SuffixableQueryByCriteria) query).getQuerySuffix(); 054 } 055 return stmt; 056 } 057}