HWBOT
  1. HWBOT
  2. HWBOT-936

Query API for competitions: startBefore and startAfter parameter cannot be used together

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: hwbot v5.3.0
    • Labels:
      None

      Description

      I can't figure out how to add two restrictions to a column with Torque. This is the current code:
      if (form.getStartBefore() != null) {
      criteria.add(ContestPeer.STARTDATE, form.getStartBefore(), Criteria.LESS_EQUAL);
      }
      if (form.getStartAfter() != null) {
      criteria.add(ContestPeer.STARTDATE, form.getStartAfter(), Criteria.GREATER_EQUAL);
      }
      But the generated query will only contain the GREATER_EQUAL restriction if both startBefore and startAfter are not null: Current Query SQL (may not be complete or applicable): SELECT FROM contest WHERE contest.hidden=0 AND contest.startDate>='20100901000000' ORDER BY contest.startDate DESC

        Activity

        Hide
        Frederik Colardyn added a comment -
        You need to use a "Criterion" object if you want to have multiple restrictions on one column.

        Eg if you want to find all achievements with current date after start date or start date null, you use the following code:

        Criteria criteria = new Criteria();
        Criterion afterstart = criteria.getNewCriterion(AchievementTypePeer.START_DATE, new Date(), Criteria.GREATER_EQUAL);
        Criterion startnull = criteria.getNewCriterion(AchievementTypePeer.START_DATE, null, Criteria.ISNULL);
        afterstart.or(startnull);

        criteria.or(startnull);
        return AchievementTypePeer.doSelect(criteria);
        Show
        Frederik Colardyn added a comment - You need to use a "Criterion" object if you want to have multiple restrictions on one column. Eg if you want to find all achievements with current date after start date or start date null, you use the following code: Criteria criteria = new Criteria(); Criterion afterstart = criteria.getNewCriterion(AchievementTypePeer.START_DATE, new Date(), Criteria.GREATER_EQUAL); Criterion startnull = criteria.getNewCriterion(AchievementTypePeer.START_DATE, null, Criteria.ISNULL); afterstart.or(startnull); criteria.or(startnull); return AchievementTypePeer.doSelect(criteria);
        Hide
        Build Server added a comment -
        Integrated in HWBOT v4 #2715 (See [http://dev.hwbot.org/job/HWBOT%20v4/2715/])
            HWBOT-936

        Query API for competitions: startBefore and startAfter parameter cannot be used together
        HWBOT-936

        Query API for competitions: startBefore and startAfter parameter cannot be used together

        dennis :
        Files :
        * /hwbot/trunk/src/main/java/org/hwbot/facade/CompetitionFacadeImpl.java

        dennis :
        Files :
        * /hwbot/trunk/src/main/java/org/hwbot/facade/CompetitionFacadeImpl.java
        Show
        Build Server added a comment - Integrated in HWBOT v4 #2715 (See [ http://dev.hwbot.org/job/HWBOT%20v4/2715/ ])      HWBOT-936 Query API for competitions: startBefore and startAfter parameter cannot be used together HWBOT-936 Query API for competitions: startBefore and startAfter parameter cannot be used together dennis : Files : * /hwbot/trunk/src/main/java/org/hwbot/facade/CompetitionFacadeImpl.java dennis : Files : * /hwbot/trunk/src/main/java/org/hwbot/facade/CompetitionFacadeImpl.java

          People

          • Assignee:
            Frederik Colardyn
            Reporter:
            Dennis Devriendt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: