Coverage Report - org.kuali.rice.core.ojb.SqlGeneratorSuffixableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
SqlGeneratorSuffixableImpl
0%
0/12
0%
0/4
2
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.ojb;
 17  
 
 18  
 import org.apache.ojb.broker.accesslayer.sql.SelectStatement;
 19  
 import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl;
 20  
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 21  
 import org.apache.ojb.broker.platforms.Platform;
 22  
 import org.apache.ojb.broker.query.Query;
 23  
 import org.apache.ojb.broker.util.logging.Logger;
 24  
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 25  
 import org.kuali.rice.core.util.RiceDebugUtils;
 26  
 
 27  
 /**
 28  
  * SqlGeneratorDefaultImpl subclass that replaced the vanilla SqlSelectStatement implementation
 29  
  * with a new {@link SuffixedSqlSelectStatement} that is {@link SuffixableQueryByCriteria} - aware.
 30  
  * This class needs to be specified as the SqlGenerator implementation in the OJB properties, to replace
 31  
  * the SqlGeneratorDefaultImpl.
 32  
  * This is a hack to introduce select-for-update functionality into OJB so the same ORM/Criteria abstractions
 33  
  * can be retained for select-for-update queries.  Select for update appears to have been added in the OJB
 34  
  * source repository, so maybe a forthcoming release will include this functionality and these kludges can be
 35  
  * removed.
 36  
  * @see SuffixedSqlSelectStatement
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  */
 39  
 public class SqlGeneratorSuffixableImpl extends SqlGeneratorDefaultImpl {
 40  0
     private Logger logger = LoggerFactory.getLogger(SqlGeneratorSuffixableImpl.class);
 41  
 
 42  
     public SqlGeneratorSuffixableImpl(Platform platform) {
 43  0
         super(platform);
 44  0
     }
 45  
 
 46  
     @Override
 47  
     public SelectStatement getPreparedSelectStatement(Query query, ClassDescriptor cld) {
 48  0
         SelectStatement sql = new SuffixedSqlSelectStatement(getPlatform(), cld, query, logger);
 49  0
         if (logger.isDebugEnabled()) {
 50  0
             boolean masochisticSqlLogging = true;
 51  0
             if ( masochisticSqlLogging ) {
 52  0
                     StringBuffer sb = RiceDebugUtils.getTruncatedStackTrace( true );
 53  0
                     logger.debug("SQL: " + sql.getStatement() + "\n" + query.getCriteria() + "\n" + sb.toString() );
 54  0
             } else {
 55  0
                 logger.debug("SQL: " + sql.getStatement() );
 56  
             }
 57  
         }
 58  0
         return sql;
 59  
     }
 60  
 }