Coverage Report - org.apache.ojb.broker.platforms.PlatformDerbyImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PlatformDerbyImpl
N/A
N/A
1.75
 
 1  
 package org.apache.ojb.broker.platforms;
 2  
 
 3  
 /* Copyright 2002-2005 The Apache Software Foundation
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 import java.sql.PreparedStatement;
 19  
 import java.sql.SQLException;
 20  
 import java.sql.Types;
 21  
 
 22  
 /**
 23  
  * This class defines specific behavior for the Derby platform.
 24  
  */
 25  
 public class PlatformDerbyImpl extends PlatformDefaultImpl
 26  
 {
 27  
     /**
 28  
      * {@inheritDoc}
 29  
      */
 30  
     public byte getJoinSyntaxType()
 31  
     {
 32  
         return SQL92_NOPAREN_JOIN_SYNTAX;
 33  
     }
 34  
 
 35  
     /**
 36  
      * {@inheritDoc}
 37  
      */
 38  
     public boolean supportsMultiColumnCountDistinct()
 39  
     {
 40  
         // Currently Derby supports COUNT DISTINCT only for one column
 41  
         return false;
 42  
     }
 43  
 
 44  
     /**
 45  
      * {@inheritDoc}
 46  
      */
 47  
     public void setObjectForStatement(PreparedStatement ps, int index, Object value, int jdbcType) throws SQLException
 48  
     {
 49  
         if (((jdbcType == Types.CHAR) || (jdbcType == Types.VARCHAR)) &&
 50  
             (value instanceof Character))
 51  
         {
 52  
             // [tomdz]
 53  
             // Currently, Derby doesn't like Character objects in the PreparedStatement
 54  
             // when using PreparedStatement#setObject(index, value, jdbcType) method
 55  
             // (see issue DERBY-773)
 56  
             // So we make a String object out of the Character object and use that instead
 57  
             super.setObjectForStatement(ps, index, value.toString(), jdbcType);
 58  
         }
 59  
         else
 60  
         {
 61  
             super.setObjectForStatement(ps, index, value, jdbcType);
 62  
         }
 63  
     }
 64  
 
 65  
     /**
 66  
      * {@inheritDoc}
 67  
      */
 68  
     public String getLastInsertIdentityQuery(String tableName)
 69  
     {
 70  
         // matthias.roth@impart.ch
 71  
         // the function is used by the org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl
 72  
                 // this call must be made before commit the insert command, so you
 73  
         // must turn off autocommit by seting the useAutoCommit="2"
 74  
         // or use useAutoCommit="1" or use a connection with autoCommit set false
 75  
         // by default (e.g. in managed environments)
 76  
         // transaction demarcation is mandatory
 77  
         return "values IDENTITY_VAL_LOCAL()";
 78  
     }
 79  
 }