db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformDefaultImpl.java PlatformHsqldbImpl.java Platform.java PlatformMySQLImpl.java
Date Sun, 16 Nov 2003 18:18:58 GMT
brj         2003/11/16 10:18:58

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformDefaultImpl.java PlatformHsqldbImpl.java
                        Platform.java PlatformMySQLImpl.java
  Log:
  added support for LIMIT
  
  Revision  Changes    Path
  1.20      +36 -0     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PlatformDefaultImpl.java	28 Oct 2003 21:08:23 -0000	1.19
  +++ PlatformDefaultImpl.java	16 Nov 2003 18:18:58 -0000	1.20
  @@ -337,4 +337,40 @@
   		java.sql.Clob aClob = rs.getClob(columnId);
   		return (rs.wasNull() ? null : aClob.getSubString(1L, (int) aClob.length()));
   	}
  +    
  +    /* (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()
  +    {
  +         return false;
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
  +     */
  +    public boolean supportsPaging()
  +    {
  +        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
  +    {
  +        ps.setInt(index, startAt - 1);              // zero based start
  +        index++;
  +        ps.setInt(index, endAt - (startAt - 1));    // number of rows to fetch
  +        index++;
  +        return index;
  +    }
  +    
   }
  
  
  
  1.5       +28 -1     db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformHsqldbImpl.java
  
  Index: PlatformHsqldbImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformHsqldbImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PlatformHsqldbImpl.java	9 May 2003 23:58:18 -0000	1.4
  +++ PlatformHsqldbImpl.java	16 Nov 2003 18:18:58 -0000	1.5
  @@ -1,5 +1,6 @@
   package org.apache.ojb.broker.platforms;
   
  +
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  @@ -78,4 +79,30 @@
       {
           return LAST_INSERT;
       }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.platforms.Platform#addPagingSql(java.lang.StringBuffer)
  +     */
  +    public void addPagingSql(StringBuffer anSqlString)
  +    {
  +        anSqlString.insert(6, " LIMIT ? ? ");
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.platforms.Platform#bindPagingParametersFirst()
  +     */
  +    public boolean bindPagingParametersFirst()
  +    {
  +        return true;
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
  +     */
  +    public boolean supportsPaging()
  +    {
  +        return true;
  +    }
  +
  +
   }
  
  
  
  1.18      +29 -1     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Platform.java	29 Jul 2003 16:54:12 -0000	1.17
  +++ Platform.java	16 Nov 2003 18:18:58 -0000	1.18
  @@ -218,4 +218,32 @@
   	 * Oracle has funky clobs.
   	 */
   	public Object getClob(ResultSet rs, int jdbcType, String columnId) throws SQLException;
  +    
  +    /**
  +     * Answer true if LIMIT or equivalent is supported
  +     * @return 
  +     */
  +    public boolean supportsPaging();
  +    
  +    /**
  +     * Add the LIMIT or equivalent to the SQL 
  +     * @return 
  +     */
  +    public void addPagingSql(StringBuffer anSqlString);
  +    
  +    /**
  +     * Answer true if the LIMIT parameters are bound before the query parameters
  +     * @return
  +     */
  +    boolean bindPagingParametersFirst();
  +    
  +    /**
  +     * Bind the Paging Parameters
  +     * @param ps
  +     * @param index parameter index
  +     * @param startAt
  +     * @param endAt
  +     * @return
  +     */
  +    public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt)
throws SQLException; 
   }
  
  
  
  1.5       +18 -0     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PlatformMySQLImpl.java	5 Aug 2003 11:44:12 -0000	1.4
  +++ PlatformMySQLImpl.java	16 Nov 2003 18:18:58 -0000	1.5
  @@ -91,4 +91,22 @@
       {
           return LAST_INSERT + tableName + LIMIT;
       }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.platforms.Platform#addPagingSql(java.lang.StringBuffer)
  +     */
  +    public void addPagingSql(StringBuffer anSqlString)
  +    {
  +        anSqlString.append(" LIMIT ?,?");
  +    }
  +
  +   
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
  +     */
  +    public boolean supportsPaging()
  +    {
  +        return true;
  +    }
  +    
   }
  
  
  

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


Mime
View raw message