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/sql SqlQueryStatement.java
Date Fri, 13 Feb 2004 17:01:22 GMT
brj         2004/02/13 09:01:22

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  do not fail criteria containing no selection-criteria
  
  Revision  Changes    Path
  1.62      +22 -20    db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- SqlQueryStatement.java	30 Dec 2003 19:15:31 -0000	1.61
  +++ SqlQueryStatement.java	13 Feb 2004 17:01:22 -0000	1.62
  @@ -117,30 +117,30 @@
       public SqlQueryStatement(SqlQueryStatement parent, Platform pf, ClassDescriptor cld,
String[] columns, Query query, Logger logger)
       {
           m_logger = logger != null ? logger : LoggerFactory.getLogger(SqlQueryStatement.class);
  -        this.m_parentStatement = parent;
  -        this.m_query = (QueryByCriteria) query;
  -        this.m_columns = columns;
  -        this.m_platform = pf;
  -        this.m_searchCld = cld;
  +        m_parentStatement = parent;
  +        m_query = (QueryByCriteria) query;
  +        m_columns = columns;
  +        m_platform = pf;
  +        m_searchCld = cld;
   
           if ((m_query == null) || (m_query.getBaseClass() == m_query.getSearchClass()))
           {
  -            this.m_baseCld = m_searchCld;
  +            m_baseCld = m_searchCld;
           }
           else
           {
  -            this.m_baseCld = cld.getRepository().getDescriptorFor(query.getBaseClass());
  +            m_baseCld = cld.getRepository().getDescriptorFor(query.getBaseClass());
           }
   
  -        this.m_root = createTableAlias(m_baseCld, null, "");
  +        m_root = createTableAlias(m_baseCld, null, "");
   
           if (m_searchCld == m_baseCld)
           {
  -            this.m_search = m_root;
  +            m_search = m_root;
           }
           else
           {
  -            this.m_search = getTableAlias(m_query.getObjectProjectionAttribute(), false,
null, null);
  +            m_search = getTableAlias(m_query.getObjectProjectionAttribute(), false, null,
null);
           }
   
   
  @@ -600,7 +600,10 @@
                   {
                       case (Criteria.OR):
                           {
  -                            statement.append(" OR ");
  +                            if (statement.length() > 0)
  +                            {
  +                                statement.append(" OR ");
  +                            }
                               statement.append(addAtStart);
                               statement.append(asSQLStatement(pc));
                               statement.append(addAtEnd);
  @@ -608,8 +611,11 @@
                           }
                       case (Criteria.AND):
                           {
  -                            statement.insert(0, "( ");
  -                            statement.append(") AND ");
  +                            if (statement.length() > 0)
  +                            {
  +                                statement.insert(0, "( ");
  +                                statement.append(") AND ");
  +                            }
                               statement.append(addAtStart);
                               statement.append(asSQLStatement(pc));
                               statement.append(addAtEnd);
  @@ -620,16 +626,12 @@
               else
               {
                   SelectionCriteria c = (SelectionCriteria) o;
  -                if (statement.length() == 0)
  -                {
  -                    appendSQLClause(c, statement);
  -                }
  -                else
  +                if (statement.length() > 0)
                   {
                       statement.insert(0, "(");
                       statement.append(") AND ");
  -                    appendSQLClause(c, statement);
                   }
  +                appendSQLClause(c, statement);
               }
           } // while
   
  
  
  

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