Fix for the DerbyPlatform error SQLDataException:The syntax of the string representation of a date/time value is incorrect - #2649
Conversation
|
Requesting @rfelcman to help review this change |
|
Please provide there some small test case or just definitions with data type used on DB side |
|
Hi Radek (@rfelcman), It is only seen for a soa application for which we cannot a unit testcase in eclipselink as I have tried several ways to try to reproduce it but unable to generate the following error If you have some suggestions/pointers for it then I can try those too |
|
While it may be difficult or impossible to share the test-case, it is easy to share the input/concrete value which gets passed to the method being changed - if that is a string, it is even better, if not, the type of that instance and some key attributes should be enough - ie debugger's copy value feature can help with this |
|
The value object being passed to method org.eclipse.persistence.platform.database.DerbyPlatform#convertToDatabaseType method is of class "java.util.Date" and its value is "Mon Mar 02 05:54:19 UTC 2026" After the call to Helper.sqlDateFromUtilDate((java.util.Date)value) the value object is of class "java.sql.Date" and its value is "2026-03-02" |
|
and what is the column definition on the DB side? Is that a String, Timestamp, Date, Time or sth else? |
|
The column definition on DB side is TIMESTAMP |
|
Thank you. The very last question I have - isn't the bug in where the return values for the PERF and normal case are turned around? |
|
I wrote a simple java code as follows to test it import java.util.Date; public class sqlDate { On running on the above code, it is getting returned by code at After changing the code at line 1272 as follows
and then re-running the test yields the same result as before "2026-03-12" |
What have you done in order to understand why it is so and/or why the time part is not included in the output? Did you check the javadoc of What happens if you update your test code to: Do you see any difference? |
|
As per https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Date.html#toString() it returns a String in yyyy-mm-dd format and it will not include any time part Also as per javadoc https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Date.html Are you saying calling the below code will return a java.sql.Date with time components set to 0
But do you see any issue with the current change/fix done to org.eclipse.persistence.platform.database.DerbyPlatform#convertToDatabaseType method I see similar code already existing for |
|
well, I'd say that if the problem is in how exactly is particular data type formatted on the output side, then overriding statement.setString(...). What is probaly prefered is thatstatement.setDate(..) gets called instead should the code get there. Does this make sense to you? This guessing without a reproducible test case is a bit challenging and time consuming :-/
|
|
or - another place to look at - ...but I don't know which code path is your case taking |
|
On removing org.eclipse.persistence.platform.database.DerbyPlatform#convertToDatabaseType method I can see that following tests which was added by #891
|
under which conditions? What do I have to do to reproduce this? On my end, |
|
I don't have the derby setup for master branch but I am running it for 2.7.15 version I have installed apache derby locally and then updated test.properties file as follows After which when I run the tests as follows then it errors out
|
|
Are you able to reproduce the error in running the test org.eclipse.persistence.jpa.test.criteria.TestCoalesceFunction#testCoalesceFunction3Date after removing org.eclipse.persistence.platform.database.DerbyPlatform#convertToDatabaseType method |
|
Yes. It is related to The code, which I removed, made that config working, but broke:
therefore I believe current state - without the method being modified here - is better the problem with this is also that it is unclear which case is this supposed to fix. In any case, the cause lies somewhere at runtime where the type conversion from |
|
basically following piece of code hidden in the mapping should be executed somewhere on the code path: before the |
|
I checked further on this and the following code is not getting executed because converter is null if (this.converter != null) { To get more info on this, I have added following debug statements and got the following outputs |
ee25887 to
f3a30a8
Compare
Signed-off-by: Vaibhav Vishal vaibhav.vishal@oracle.com
Signed-off-by: Vaibhav Vishal vaibhav.vishal@oracle.com
Signed-off-by: Vaibhav Vishal vaibhav.vishal@oracle.com
|
Requesting to help review it further |
|
Waiting for the further review on this |
|
Requesting to help review it further |
|
Waiting for the further review on this |
|
Please help review this |
|
@robertpatrick one more to check, from our commiter candidate Vaibhav Vishal |
The org.eclipse.persistence.platform.database.DerbyPlatform#convertToDatabaseType method returns a java.sql.Date which doesn't include the time due to which some applications throws the following exception
java.sql.SQLDataException: The syntax of the string representation of a date/time value is incorrect.
So a fix has been done to return appropriate and correct values
Signed-off-by: Vaibhav Vishal vaibhav.vishal@oracle.com