Issue Details (XML | Word | Printable)

Key: TORQUE-42
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Thomas Vandahl
Reporter: Federico Fissore
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Torque

Criteria.andDate missing getTime() method call

Created: 12/Jul/06 06:29 PM   Updated: 26/Nov/06 06:23 PM
Return to search
Component/s: Runtime
Affects Version/s: 3.2
Fix Version/s: 3.3

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works Criteria-3.2.patch 2006-07-12 06:30 PM Federico Fissore 0.8 kB
Environment: java5, tomcat 5.5.17

Resolution Date: 14/Jul/06 03:59 AM


 Description  « Hide
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

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #421692 Thu Jul 13 19:44:40 UTC 2006 tv Fixed Criteria.andDate() methods to call getTime() like the addDate
methods do. Added a test case to check this. Thanks to Federico Fissore
for the Criteria patch. Fixes TORQUE-42.
Files Changed
MODIFY /db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
MODIFY /db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java