Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-42

Criteria.andDate missing getTime() method call

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3
    • Component/s: Runtime
    • Labels:
      None
    • Environment:
      java5, tomcat 5.5.17

      Description

      Hello all,

      there is a bug in Criteria.andDate: the call to the method getTime() is missing while it is present in Criteria.addDate

      To exploit it use a code like

      calendar.setTime(new Date());
      crit.addDate(GpsLocationPeer.LAST_UPDATE, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), Criteria.GREATER_EQUAL);

      calendar.add(Calendar.DAY_OF_MONTH, 1);
      crit.andDate(GpsLocationPeer.LAST_UPDATE, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), Criteria.LESS_THAN);

      This leads to a SQLException due to incorrect sql query creation.
      That is easy to see with Criteria.toString()

      Adding the missing method call solves the problem

      Please, check the attached patch. Thank you

        Attachments

        1. Criteria-3.2.patch
          0.8 kB
          Federico Fissore

          Activity

            People

            • Assignee:
              tv Thomas Vandahl
              Reporter:
              fridrik Federico Fissore
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: