You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2004/02/14 21:59:53 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformDefaultImpl.java Platform.java PlatformMySQLImpl.java PlatformMsAccessImpl.java PlatformMsSQLServerImpl.java

brj         2004/02/14 12:59:53

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformDefaultImpl.java Platform.java
                        PlatformMySQLImpl.java PlatformMsAccessImpl.java
                        PlatformMsSQLServerImpl.java
  Log:
  new method for dbms-dependent concatenate
  
  Revision  Changes    Path
  1.23      +38 -6     db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
  
  Index: PlatformDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- PlatformDefaultImpl.java	24 Jan 2004 00:08:58 -0000	1.22
  +++ PlatformDefaultImpl.java	14 Feb 2004 20:59:53 -0000	1.23
  @@ -333,14 +333,14 @@
           throw new UnsupportedOperationException("This feature is not supported by this implementation");
       }
   
  -    /* (non-Javadoc)
  +    /**
        * @see org.apache.ojb.broker.platforms.Platform#addPagingSql(java.lang.StringBuffer)
        */
       public void addPagingSql(StringBuffer anSqlString)
       {
       }
       
  -    /* (non-Javadoc)
  +    /**
        * @see org.apache.ojb.broker.platforms.Platform#bindPagingParametersFirst()
        */
       public boolean bindPagingParametersFirst()
  @@ -348,7 +348,7 @@
            return false;
       }
   
  -    /* (non-Javadoc)
  +    /**
        * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
        */
       public boolean supportsPaging()
  @@ -356,7 +356,7 @@
           return false;
       }
   
  -    /* (non-Javadoc)
  +    /**
        * @see org.apache.ojb.broker.platforms.Platform#bindPagingParameters(java.sql.PreparedStatement, int, int, int)
        */
       public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt) throws SQLException
  @@ -367,5 +367,37 @@
           index++;
           return index;
       }
  -    
  +
  +    /**
  +     * Answer the Character for Concatenation
  +     */      
  +    protected String getConcatenationCharacter()
  +    {
  +        return "||";
  +    }
  +   
  +    /**
  +     * @see org.apache.ojb.broker.platforms.Platform#concatenate(java.lang.String[])
  +     */
  +    public String concatenate(String[] theColumns)
  +    {
  +        if (theColumns.length == 1)
  +        {
  +            return theColumns[0];
  +        }
  +
  +        StringBuffer buf = new StringBuffer();
  +        String concatChar = getConcatenationCharacter();
  +        
  +        for (int i = 0; i < theColumns.length; i++)
  +        {
  +            if (i > 0)
  +            {
  +                buf.append(" " + concatChar + " ");
  +            }
  +            buf.append(theColumns[i]);
  +        }
  +
  +        return buf.toString();
  +    }
   }
  
  
  
  1.21      +13 -2     db-ojb/src/java/org/apache/ojb/broker/platforms/Platform.java
  
  Index: Platform.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/Platform.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Platform.java	24 Jan 2004 00:08:58 -0000	1.20
  +++ Platform.java	14 Feb 2004 20:59:53 -0000	1.21
  @@ -243,5 +243,16 @@
        * @param endAt
        * @return
        */
  -    public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt) throws SQLException; 
  +    public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt) throws SQLException;
  +    
  +    /**
  +     * Concatenate the columns </br>
  +     * ie: col1 || col2 || col3 (ANSI)</br>
  +     * ie: col1 + col2 + col3 (MS SQL-Server)</br>
  +     * ie: concat(col1, col2, col3) (MySql)
  +     * 
  +     * @param theColumns
  +     * @return the concatenated String 
  +     */
  +    public String concatenate(String[] theColumns);
   }
  
  
  
  1.11      +26 -1     db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMySQLImpl.java
  
  Index: PlatformMySQLImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMySQLImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PlatformMySQLImpl.java	30 Dec 2003 21:39:02 -0000	1.10
  +++ PlatformMySQLImpl.java	14 Feb 2004 20:59:53 -0000	1.11
  @@ -148,4 +148,29 @@
           return true;
       }
   
  +    /**
  +     * @see org.apache.ojb.broker.platforms.Platform#concatenate(java.lang.String[])
  +     */
  +    public String concatenate(String[] theColumns)
  +    {
  +        if (theColumns.length == 1)
  +        {
  +            return theColumns[0];
  +        }
  +        
  +        StringBuffer buf = new StringBuffer();
  +        
  +        buf.append("concat(");
  +        for (int i = 0; i < theColumns.length; i++)
  +        {
  +            if (i > 0)
  +            {
  +                buf.append(",");
  +            }
  +            buf.append(theColumns[i]);
  +        }
  +
  +        buf.append(")");
  +        return buf.toString();
  +    }    
   }
  
  
  
  1.8       +9 -1      db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsAccessImpl.java
  
  Index: PlatformMsAccessImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsAccessImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PlatformMsAccessImpl.java	28 Nov 2003 16:18:20 -0000	1.7
  +++ PlatformMsAccessImpl.java	14 Feb 2004 20:59:53 -0000	1.8
  @@ -142,4 +142,12 @@
               }
           }
       }
  +    
  +    /**
  +     * Answer the Character for Concatenation
  +     */
  +    protected String getConcatenationCharacter()
  +    {
  +        return "&";
  +    }    
   }
  
  
  
  1.6       +60 -66    db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsSQLServerImpl.java
  
  Index: PlatformMsSQLServerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsSQLServerImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PlatformMsSQLServerImpl.java	19 Dec 2003 18:04:06 -0000	1.5
  +++ PlatformMsSQLServerImpl.java	14 Feb 2004 20:59:53 -0000	1.6
  @@ -5,66 +5,50 @@
   import java.sql.Types;
   import java.sql.SQLException;
   
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  +/*
  + * ==================================================================== The Apache Software
  + * License, Version 1.1
  + * 
  + * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
  + * 
  + * Redistribution and use in source and binary forms, with or without modification, are permitted
  + * provided that the following conditions are met:
  + *  1. Redistributions of source code must retain the above copyright notice, this list of
  + * conditions and the following disclaimer.
  + *  2. Redistributions in binary form must reproduce the above copyright notice, this list of
  + * conditions and the following disclaimer in the documentation and/or other materials provided
  + * with the distribution.
  + *  3. The end-user documentation included with the redistribution, if any, must include the
  + * following acknowledgment: "This product includes software developed by the Apache Software
  + * Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the
  + * software itself, if and wherever such third-party acknowledgments normally appear.
  + *  4. The names "Apache" and "Apache Software Foundation" and "Apache ObjectRelationalBridge" must
  + * not be used to endorse or promote products derived from this software without prior written
  + * permission. For written permission, please contact apache@apache.org.
  + *  5. Products derived from this software may not be called "Apache", "Apache
  + * ObjectRelationalBridge", nor may "Apache" appear in their name, without prior written permission
  + * of the Apache Software Foundation.
  + * 
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR
  + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  + * 
  + * This software consists of voluntary contributions made by many individuals on behalf of the
  + * Apache Software Foundation. For more information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
   
  -
   /**
  - * This class extends <code>PlatformDefaultImpl</code> and defines specific
  - * behavior for the Microsoft SQL Server platform.
  - *
  - * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
  + * This class extends <code>PlatformDefaultImpl</code> and defines specific behavior for the
  + * Microsoft SQL Server platform.
  + * 
  + * @author <a href="mailto:thma@apache.org">Thomas Mahler <a>
    * @version $Id$
    */
   
  @@ -81,7 +65,7 @@
       }
   
       public CallableStatement prepareNextValProcedureStatement(Connection con, String procedureName,
  -                                                              String sequenceName) throws PlatformException
  +            String sequenceName) throws PlatformException
       {
           try
           {
  @@ -96,13 +80,23 @@
               throw new PlatformException(e);
           }
       }
  -    
  -	 public String getLastInsertIdentityQuery(String tableName)
  -	 {
  -		// matthias.roth@impart.ch
  -		// the function is used by the org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl
  -		// this call must be made before commit the insert cammand, so you
  -		// must turn off autocommit by setting the useAutoCommit="2"
  -	 	return "SELECT @@IDENTITY AS id FROM "+tableName;
  -	 }    
  +
  +    public String getLastInsertIdentityQuery(String tableName)
  +    {
  +        // matthias.roth@impart.ch
  +        // the function is used by the
  +        // org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl
  +        // this call must be made before commit the insert cammand, so you
  +        // must turn off autocommit by setting the useAutoCommit="2"
  +        return "SELECT @@IDENTITY AS id FROM " + tableName;
  +    }
  +
  +    /**
  +     * Answer the Character for Concatenation
  +     */
  +    protected String getConcatenationCharacter()
  +    {
  +        return "+";
  +    }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org