Skip to content
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

Add a couple missing java.time types to StatementCreatorUtils #30123

Merged
merged 2 commits into from
Apr 4, 2023

Conversation

simonbasle
Copy link
Contributor

This commit adds mapping for two types from the java.time package,
complementing the types that are already translatable to Sql types
TIME, DATE and TIMESTAMP:

  • OffsetTime maps to a TIME_WITH_TIMEZONE
  • OffsetDateTime maps to a TIMESTAMP_WITH_TIMEZONE

This is in accordance with the B.4 table provided in the JDBC 4.2
specification.

When preparing statements, these java.time types use the setObject
method. Tests covering the 5 java.time classes have also been added.

See gh-28778
See gh-28527

This commit adds mapping for two types from the `java.time` package,
complementing the types that are already translatable to Sql types
TIME, DATE and TIMESTAMP:
 - `OffsetTime` maps to a `TIME_WITH_TIMEZONE`
 - `OffsetDateTime` maps to a `TIMESTAMP_WITH_TIMEZONE`

This is in accordance with the B.4 table provided in the JDBC 4.2
specification.

When preparing statements, these `java.time` types use the `setObject`
method. Tests covering the 5 `java.time` classes have also been added.

See spring-projectsgh-28778
See spring-projectsgh-28527
@simonbasle simonbasle added this to the 6.0.8 milestone Mar 15, 2023
@simonbasle simonbasle added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Mar 15, 2023
@simonbasle simonbasle self-assigned this Mar 15, 2023
@simonbasle simonbasle requested a review from a team March 15, 2023 16:44
@simonbasle
Copy link
Contributor Author

for reference, here's an excerpt of Table B.4 in the JDBC 4.2 specification:

PreparedStatement.setObject, PreparedStatement.setNull, RowSet.setNull and
RowSet.setObject use the mapping shown TABLE B-4 when no parameter specifying a
target JDBC type is provided.

Java Type SQL Type
java.sql.Date
DATE
java.sql.Time
TIME
java.sql.Timestamp
TIMESTAMP
java.util.Calendar
TIMESTAMP
java.util.Date
TIMESTAMP
java.time.LocalDate
DATE
java.time.LocalTime
TIME
java.time.LocalDateTime
TIMESTAMP
java.time.OffsetTime
TIME_WITH_TIMEZONE
java.time.OffsetDatetime
TIMESTAMP_WITH_TIMEZONE

@simonbasle simonbasle merged commit 90b0f45 into spring-projects:main Apr 4, 2023
@sbrannen sbrannen removed request for a team and jhoeller April 5, 2023 08:26
mdeinum pushed a commit to mdeinum/spring-framework that referenced this pull request Jun 29, 2023
This commit adds mapping for two types from the `java.time` package,
complementing the types that are already translatable to Sql types
TIME, DATE and TIMESTAMP:
 - `OffsetTime` maps to a `TIME_WITH_TIMEZONE`
 - `OffsetDateTime` maps to a `TIMESTAMP_WITH_TIMEZONE`

This is in accordance with the B.4 table provided in the JDBC 4.2
specification.

When preparing statements, these `java.time` types use the `setObject`
method. Tests covering the 5 `java.time` classes have also been added.

See spring-projectsgh-28778
See spring-projectsgh-28527
Closes spring-projectsgh-30123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant