This issue has been created
 
 
Admin Tools Application / cid:jira-generated-image-avatar-c72811fe-919b-4f4e-91a4-66628fcb684f ADMINTOOL-99 Open

Shrinking the recycle bins compares the deletion date with a string

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-88d2b558-6b7f-4071-afff-b3959caa6e98 Thomas Mortagne created this issue on 17/Nov/26 15:11
 
Summary: Shrinking the recycle bins compares the deletion date with a string
Issue Type: cid:jira-generated-image-avatar-c72811fe-919b-4f4e-91a4-66628fcb684f Bug
Affects Versions: 4.5.7
Assignee: Unassigned
Components: Data altering tool
Created: 17/Nov/26 15:11
Priority: cid:jira-generated-image-static-major-6df4a80c-6ceb-4875-8037-a569bf4ae6e3 Major
Reporter: Thomas Mortagne
Description:

Admin.ShrinkRecycleBins compares the deletion date of the deleted documents and attachments with a string, in 3 queries:

select count(doc) from XWikiDeletedDocument doc where doc.date < '${getAgeWhereClause(age)}'
select count(doc) from DeletedAttachment doc where doc.date < '${getAgeWhereClause(age)}'
select doc.fullName from XWikiDeletedDocument doc where doc.date < '${getAgeWhereClause(0)}'

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 date as a java.util.Date query parameter instead. This works with all the databases and all the Hibernate versions.