arminw      2005/01/13 07:54:31

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        StatementsForClassImpl.java
  Log:
  fix by Vadim Gritsenko:

  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.
  
  Revision  Changes    Path
  1.25      +30 -8     
db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java
  
  Index: StatementsForClassImpl.java
  ===================================================================
  RCS file: 
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- StatementsForClassImpl.java       14 Sep 2004 16:03:33 -0000      1.24
  +++ StatementsForClassImpl.java       13 Jan 2005 15:54:31 -0000      1.25
  @@ -87,10 +87,10 @@
        * <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
  @@ -105,7 +105,7 @@
                   con,
                   deleteSql,
                   Query.NOT_SCROLLABLE,
  -                usePreparedStatement());
  +                usePreparedDeleteStatement());
           }
           catch (SQLException ex)
           {
  @@ -130,6 +130,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)
  @@ -142,7 +153,7 @@
                   con,
                   insertSql,
                   Query.NOT_SCROLLABLE,
  -                usePreparedStatement());
  +                usePreparedInsertStatement());
           }
           catch (SQLException ex)
           {
  @@ -184,6 +195,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)
  @@ -196,7 +218,7 @@
                   con,
                   updateSql,
                   Query.NOT_SCROLLABLE,
  -                usePreparedStatement());
  +                usePreparedUpdateStatement());
           }
           catch (SQLException ex)
           {
  @@ -214,7 +236,7 @@
                   con,
                   updateFieldsSql,
                   Query.NOT_SCROLLABLE,
  -                usePreparedStatement());
  +                usePreparedUpdateStatement());
           }
           catch (SQLException ex)
           {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to