db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: [PATCH] Fix procedure checks in StatementsForClassImpl
Date Thu, 13 Jan 2005 15:54:12 GMT
Hi Vadim,

checked in your patch.

regards,
Armin

Vadim Gritsenko wrote:
> [I did it again - forgot the attachement]
> 
> Hi all,
> 
> This patch fixes incorrect test in StatementsForClassImpl. Currently for
> create/update/delete procedures it has single check, in 
> usePreparedStatement:
> 
>        return !((classDescriptor.getUpdateProcedure() != null) &&
>                (classDescriptor.getUpdateProcedure().hasReturnValues()));
> 
> Which means that if update procedure is present, it will attempt to call a
> procedure for create/delete as well - even if none is configured.
> 
> Hope somebody can apply the patch. And please review also:
>   http://marc.theaimsgroup.com/?l=ojb-dev&m=110433444012727
>   http://marc.theaimsgroup.com/?l=ojb-dev&m=110433552712812
> 
> 
> Thanks,
> Vadim
> 
> 
> ------------------------------------------------------------------------
> 
> Index: src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java
> ===================================================================
> RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java,v
> retrieving revision 1.22
> diff -u -r1.22 StatementsForClassImpl.java
> --- src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java      9 Apr
2004 13:22:29 -0000       1.22
> +++ src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java      11 Jan
2005 15:15:41 -0000
> @@ -91,13 +91,13 @@
>  
>      /**
>       * Answer true if a PreparedStatement has to be used
> -     * <br>false for a CallableStatement 
> +     * <br>false for a CallableStatement
>       * @return
>       */
> -    protected boolean usePreparedStatement()
> +    protected boolean usePreparedDeleteStatement()
>      {
> -        return !((classDescriptor.getUpdateProcedure() != null) && 
> -                (classDescriptor.getUpdateProcedure().hasReturnValues()));
> +        return !(classDescriptor.getDeleteProcedure() != null &&
> +                classDescriptor.getDeleteProcedure().hasReturnValues());
>      }
>  
>      public PreparedStatement getDeleteStmt(Connection con) throws SQLException
> @@ -112,7 +112,7 @@
>                  con,
>                  deleteSql,
>                  Query.NOT_SCROLLABLE,
> -                usePreparedStatement());
> +                usePreparedDeleteStatement());
>          }
>          catch (SQLException ex)
>          {
> @@ -137,6 +137,17 @@
>          return stmt;
>      }
>  
> +    /**
> +     * Answer true if a PreparedStatement has to be used
> +     * <br>false for a CallableStatement
> +     * @return
> +     */
> +    protected boolean usePreparedInsertStatement()
> +    {
> +        return !(classDescriptor.getInsertProcedure() != null &&
> +                classDescriptor.getInsertProcedure().hasReturnValues());
> +    }
> +
>      public PreparedStatement getInsertStmt(Connection con) throws SQLException
>      {
>          if (insertSql == null)
> @@ -149,7 +160,7 @@
>                  con,
>                  insertSql,
>                  Query.NOT_SCROLLABLE,
> -                usePreparedStatement());
> +                usePreparedInsertStatement());
>          }
>          catch (SQLException ex)
>          {
> @@ -191,6 +210,17 @@
>          }
>      }
>  
> +    /**
> +     * Answer true if a PreparedStatement has to be used
> +     * <br>false for a CallableStatement
> +     * @return
> +     */
> +    protected boolean usePreparedUpdateStatement()
> +    {
> +        return !(classDescriptor.getUpdateProcedure() != null &&
> +                classDescriptor.getUpdateProcedure().hasReturnValues());
> +    }
> +
>      public PreparedStatement getUpdateStmt(Connection con) throws SQLException
>      {
>          if (updateSql == null)
> @@ -203,7 +233,7 @@
>                  con,
>                  updateSql,
>                  Query.NOT_SCROLLABLE,
> -                usePreparedStatement());
> +                usePreparedUpdateStatement());
>          }
>          catch (SQLException ex)
>          {
> @@ -225,14 +255,14 @@
>  
>      /**
>       * prepares a statement with parameters that should work with most RDBMS
> -     * 
> +     *
>       * @param con the connection to utilize
>       * @param sql the sql syntax to use when creating the statement.
>       * @param scrollable determines if the statement will be scrollable.
>       * @param createPreparedStatement if <code>true</code>, then a
>       * {@link PreparedStatement} will be created.  if <code>false</code>,
then
> -     * a {@link CallableStatement} will be created.
> -     * 
> +     * a {@link java.sql.CallableStatement} will be created.
> +     *
>       * @return a statement that can be used to execute the syntax contained in
>       * the <code>sql</code> argument.
>       */
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org

---------------------------------------------------------------------
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