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/accesslayer JdbcAccessImpl.java
Date Sun, 06 Nov 2005 09:33:55 GMT
brj         2005/11/06 01:33:55

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        JdbcAccessImpl.java
  Log:
  check type of criteria/subcriteria
  (by Patrick Byrne)
  
  Revision  Changes    Path
  1.43      +23 -13    db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
  
  Index: JdbcAccessImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- JdbcAccessImpl.java	5 Nov 2005 16:15:01 -0000	1.42
  +++ JdbcAccessImpl.java	6 Nov 2005 09:33:55 -0000	1.43
  @@ -1324,32 +1324,42 @@
        * @param cld the ClassDescriptor
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, ExistsCriteria crit, ClassDescriptor
cld) throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, ExistsCriteria crit, ClassDescriptor
cld)
  +            throws SQLException
       {
  -        QueryByCriteria subQuery = (QueryByCriteria) crit.getValue();
  +        Query subQuery = (Query) crit.getValue();
  +        Criteria criteria = null;
   
  -        if(subQuery.getCriteria() != null && !subQuery.getCriteria().isEmpty())
  +        // check type of subquery
  +        if (subQuery instanceof QueryByCriteria)
           {
  -            // if query has criteria, bind them
  -            return bindStatement(stmt, subQuery.getCriteria(), cld.getRepository().getDescriptorFor(subQuery.getSearchClass()),
index);
  +            criteria = ((QueryByCriteria) subQuery).getCriteria();
           }
  -        else
  +
  +        // if query has criteria, bind them
  +        if (criteria != null && !criteria.isEmpty())
           {
  -            // otherwise, just ignore it
  -            return index;
  +            return bindStatement(stmt, criteria, cld.getRepository().getDescriptorFor(subQuery.getSearchClass()),
index);
           }
  +
  +        return index;
       }
   
       /** bind a Query based Select Statement */
       public int bindStatement(PreparedStatement stmt, Query query, ClassDescriptor cld,
int param) throws SQLException
       {
           int index;
  -        QueryByCriteria qbq = (QueryByCriteria) query;
   
  -        index = bindStatement(stmt, qbq.getCriteria(), cld, param);
  -        index = bindStatement(stmt, qbq.getHavingCriteria(), cld, index);
  +        // check type of subquery
  +        if (query instanceof QueryByCriteria)
  +        {
  +            QueryByCriteria qbq = (QueryByCriteria) query;
  +            index = bindStatement(stmt, qbq.getCriteria(), cld, param);
  +            index = bindStatement(stmt, qbq.getHavingCriteria(), cld, index);
  +            return index;
  +        }
   
  -        return index;
  +        return param;
       }
   
       /** bind a Query based Select Statement */
  
  
  

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