This issue has been created
 
 
Holiday Request / cid:jira-generated-image-avatar-ab09d7f6-772a-4659-9730-a516758a18fe HOLIDAYREQ-44 Open

The JSON service compares the start and end dates with strings

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-53b17b2a-2893-4922-b7cf-c4c2f0f2cf55 Thomas Mortagne created this issue on 17/Nov/26 15:11
 
Summary: The JSON service compares the start and end dates with strings
Issue Type: cid:jira-generated-image-avatar-ab09d7f6-772a-4659-9730-a516758a18fe Bug
Affects Versions: 1.3.2
Assignee: Unassigned
Created: 17/Nov/26 15:11
Priority: cid:jira-generated-image-static-major-8cb9566e-e3db-48d6-b59d-fbde99dc32a3 Major
Reporter: Thomas Mortagne
Difficulty: Unknown
Description:

HolidayRequest.HolidayRequestJSON compares the start and end date properties of the requests with strings:

startDate.value <= '${end}' and endDate.value >= '${start}'

Since Hibernate 6, HQL checks the types of both sides of a comparison when the query is parsed, and rejects incompatible ones (SemanticException: Cannot compare left expression of type ... with right expression of type ...). XWiki is moving to Hibernate 7 (XWIKI-19708), where these queries will fail on every database. With Hibernate 5 the literal is copied as is in the SQL, so the queries rely on the database converting it implicitly, which not all databases do.

On Oracle, this already depends on the date format of the database session (NLS_DATE_FORMAT).

Bind the dates as java.util.Date query parameters instead (which also avoids injecting request parameters in the query). This works with all the databases and all the Hibernate versions.