Coverage Report - org.apache.ojb.broker.platforms.PlatformMsSQLServerImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PlatformMsSQLServerImpl
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.CallableStatement;
 19  
 import java.sql.Connection;
 20  
 import java.sql.Types;
 21  
 import java.sql.SQLException;
 22  
 
 23  
 /**
 24  
  * This class extends <code>PlatformDefaultImpl</code> and defines specific behavior for the
 25  
  * Microsoft SQL Server platform.
 26  
  * 
 27  
  * @version $Id: PlatformMsSQLServerImpl.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
 28  
  */
 29  
 public class PlatformMsSQLServerImpl extends PlatformDefaultImpl
 30  
 {
 31  
     /**
 32  
      * Get join syntax type for this RDBMS - one on of the constants from JoinSyntaxType interface
 33  
      * MBAIRD: MS SQL Server 2000 actually supports both types, but due to a problem with the sql
 34  
      * generator, we opt to have no parens.
 35  
      */
 36  
     public byte getJoinSyntaxType()
 37  
     {
 38  
         return SQL92_NOPAREN_JOIN_SYNTAX;
 39  
     }
 40  
 
 41  
     public CallableStatement prepareNextValProcedureStatement(Connection con, String procedureName,
 42  
             String sequenceName) throws PlatformException
 43  
     {
 44  
         try
 45  
         {
 46  
             String sp = "{?= call " + procedureName + " (?)}";
 47  
             CallableStatement cs = con.prepareCall(sp);
 48  
             cs.registerOutParameter(1, Types.INTEGER);
 49  
             cs.setString(2, sequenceName);
 50  
             return cs;
 51  
         }
 52  
         catch (SQLException e)
 53  
         {
 54  
             throw new PlatformException(e);
 55  
         }
 56  
     }
 57  
 
 58  
     public String getLastInsertIdentityQuery(String tableName)
 59  
     {
 60  
         /*
 61  
         More info about the used identity-query see JIRA OJB-77
 62  
         http://issues.apache.org/jira/browse/OJB-77
 63  
 
 64  
         As suggested in OJB-77 the latest recommendation from MS was to
 65  
         use function "SELECT SCOPE_IDENTITY()" to get the latest generated identity
 66  
         for the current session and scope:
 67  
         "SCOPE_IDENTITY and @@IDENTITY will return last identity values generated in
 68  
         any table in the current session. However, SCOPE_IDENTITY returns values
 69  
         inserted only within the current scope; @@IDENTITY is not limited to a
 70  
         specific scope."
 71  
         */
 72  
         return "SELECT SCOPE_IDENTITY()";
 73  
     }
 74  
 
 75  
     /**
 76  
      * Answer the Character for Concatenation
 77  
      */
 78  
     protected String getConcatenationCharacter()
 79  
     {
 80  
         return "+";
 81  
     }
 82  
 
 83  
 }