Bug 382868 - [DB] Problem with Date parameter in CDOQuery
Summary: [DB] Problem with Date parameter in CDOQuery
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.db (show other bugs)
Version: 4.10   Edit
Hardware: PC Windows XP
: P3 critical with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords: greatbug, helpwanted
Depends on:
Blocks:
 
Reported: 2012-06-18 10:09 EDT by Robert Maier CLA
Modified: 2020-12-11 10:33 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Maier CLA 2012-06-18 10:09:28 EDT
Build Identifier: M20110909-1335

Using dbStore with DB2 creating a sql statement with data type java.util.Date throws a SQL Exception. (Not by using dbStore with H2)
We have seen, that CDO during building the sql statement is using 
Date#toString() which returns e.g. Thue Jun 2012. DB2 doesn't accept this date string.

Reproducible: Always

Steps to Reproduce:
1. Select * from aTable where validTo > aDate
2.
3.
Comment 1 Robert Maier CLA 2012-06-21 04:43:29 EDT
When creating an object is in the CDOQuery CDOQueryImpl class in a hashmap of the columns of a table name as key and the object type is set as a value.
 Especially in our case it is the table column named validTo and an object of type java.util.Date. HashMap # Entry #HashMap toString returns validTo = Thu Jun 21 09:16:46 EDT 2012th
 With this format of date strings deals dbStore with H2, but not deal with DB2.

 In CDODataOutputImpl at line 413 of a CDOTypeImpl CDOModelUtil getPrimitveType # () is set as org.eclipse.emf.cdo.common.model.CDOType.Date.
 This value is set in line 191 org.eclipse.emf.cdo.server.internal.db.SQLQueryHandler in the class in the prepared statement.
 This is in line 258, the exception "problem while executing SQL query:" thrown.
Comment 2 Eike Stepper CLA 2012-06-25 05:45:55 EDT
commit d21666610ed6f93201f660b323d286ac18259fe6

Unfortunately this fix breaks queries for TIMESTAMP columns because java.sql.Date does not contain (or suppresses) the time portion. Investigating...
Comment 3 Eike Stepper CLA 2012-08-14 22:50:07 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 4 Eike Stepper CLA 2013-06-29 12:15:48 EDT
We'll try to address open problems in 4.3 (master) first and then port fixes back to 4.2.
Comment 5 Eike Stepper CLA 2015-07-14 02:06:58 EDT
Moving all open bugzillas to 4.5.
Comment 6 Eike Stepper CLA 2016-07-31 00:50:09 EDT
Moving all unaddressed bugzillas to 4.6.
Comment 7 Philippe EUGENE CLA 2017-07-12 05:19:15 EDT
There is also this problem with a PostgreSQL backend.
The unit test SQLQueryTest#testDateParameter failed with an SQL Exception.
Conversion error between java.util.Date an the type java.sql.Date
Comment 8 Eike Stepper CLA 2017-12-28 01:12:00 EST
Moving all open bugs to 4.7
Comment 9 Eike Stepper CLA 2019-11-08 02:09:15 EST
Moving all unresolved issues to version 4.8-
Comment 10 Eike Stepper CLA 2019-12-13 12:45:52 EST
Moving all unresolved issues to version 4.9
Comment 11 Eike Stepper CLA 2020-04-03 04:11:02 EDT
I assume that this is fixed now with the changes of bug 546872.
In particular query parameter value conversion is now delegated to the DBAdapter and can be adjusted there.
Comment 12 Eike Stepper CLA 2020-12-11 10:24:29 EST
Closing.
Comment 13 Eike Stepper CLA 2020-12-11 10:33:18 EST
Closing.