-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attribute Converter not successfully called with Timestamp type #2101
Comments
Sorry but in this case for
In case of Correct converter (test case) is attached. There two pure JDBC tests Oracle JDBC driver 19.x has JDK and API TIMESTAMPTZ limits. I'd like recommend use latest one 23.3.0.23.09 . |
Thanks for the tip. I'll give the 23c JDBC driver a try. We can't switch to the TIMESTAMPTZ object because it's not portable across DBMSs. We'd be locked to Oracle JDBC so our unit tests on HSQLDB wouldn't work (or any other use case on any other DBMS). Our prior JPA provider considers the JDBC object types used in converters when reading from ResultSets, and calls the appropriate types getters, which helps in cases like this since it reads those types transparently. The JPA specification suggests that conversions should be supported for all basic types [1], so it seems like a case where the converter accepts Timestamp (or even OffsetDatetime, which fails similarly if used instead of Timestamp) should work. |
Upgrading to 23.3.0.23.09 doesn't seem to help this use case. The converter is still fed with a TIMESTAMPTZ object that doesn't implement Timestamp or OffsetDateTime. |
It was mentioned for provided test case due this: |
I appreciate the clarification. Unfortunately, I don't see a portable way to do this apart from customizing the platform. The converter is meant to take a JDBC-supported type, like java.sql.Timestamp or java.time.OffsetDatetime, but the trip through org.eclipse.persistence.platform.database.OraclePlatform.getObjectFromResultSet(ResultSet, int, int, AbstractSession) doesn't account for that like it does for the older temporal types. |
Try to use org.eclipse.persistence.platform.database.oracle.Oracle23Platform instead |
That's what it does automatically. There's nothing special in there in 4.0: https://github.com/eclipse-ee4j/eclipselink/blob/4.0.2/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/Oracle23Platform.java It looks like #1969 made some changes here in master, but it doesn't look like they'd help offset types - only local ones. |
I did not write org.eclipse.persistence.platform.database.Oracle23Platform, I wrote org.eclipse.persistence.platform.database.oracle.Oracle23Platform |
I see. I didn't even have that jar on the classpath, and don't see that platform mentioned in the main documentation, but that does seem to help with this scenario. Is this the one we're meant to use? Why are there 2? What are the differences between the one in the core jar and the one in the Oracle jar? |
Closing this based on the solution provided, It would be helpful for those working toward uptake of this library if there wasn't a need for an additional jar, and a code path that isn't as robust for lack of it. |
Describe the bug
It appears to be impossible to work with java.time.Instant fields on Oracle TIMESTAMP(6) WITH TIME ZONE fields. The following occurs when the converter is called because a nonstandard object is read from the driver.
To Reproduce
Create a persistence unit like this:
And an entity like this:
And a converter like this:
And attempt to retrieve it from the database:
persistence.xml
settings or related system properties (in case of JPA) - See aboveExpected behavior
The attribute converter should be supplied with a reasonable JDBC object type that corresponds with the converter's database value type, like java.sql.Timestamp.
Additional context
The same occurs when working with java.time datatypes. This happens when the records are read from the database, and I'm not seeing an apparent way to work around it.
The text was updated successfully, but these errors were encountered: