From 8da21570b5e408dee9fce8adffa54ebb47055130 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Wed, 9 Aug 2023 11:15:14 +0200 Subject: [PATCH] add support for Instant and Year and clarify JDBC mappings for basic types see #163 --- spec/src/main/asciidoc/appendixes.adoc | 2 ++ spec/src/main/asciidoc/ch02-entities.adoc | 17 +++++++----- .../ch11-metadata-for-or-mapping.adoc | 27 ++++++++++++------- spec/src/main/asciidoc/related-documents.adoc | 2 +- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/spec/src/main/asciidoc/appendixes.adoc b/spec/src/main/asciidoc/appendixes.adoc index 6e2ab49e..d4244cdd 100644 --- a/spec/src/main/asciidoc/appendixes.adoc +++ b/spec/src/main/asciidoc/appendixes.adoc @@ -106,6 +106,8 @@ Clarified `SqlResultSetMapping` with multiple ``EntityResult``s and conflicting Added support for Java record types as embeddable classes +Added support for _java.time.Instant_ and _java.time.Year_ and clarified JDBC mappings for basic types + Added `||` string concatenation operator Added _getSingleResultOrNull()_ to _Query_, _TypedQuery_, _StoredProcedureQuery_ diff --git a/spec/src/main/asciidoc/ch02-entities.adoc b/spec/src/main/asciidoc/ch02-entities.adoc index 8f69147c..ed62709e 100644 --- a/spec/src/main/asciidoc/ch02-entities.adoc +++ b/spec/src/main/asciidoc/ch02-entities.adoc @@ -170,6 +170,7 @@ _java.sql.Date_, _java.sql.Time_, _java.sql.Timestamp_, _byte[]_, _Byte[]_, _char[]_, _Character[]_, _java.time.LocalDate_, _java.time.LocalTime_, _java.time.LocalDateTime_, _java.time.OffsetTime_, _java.time.OffsetDateTime_, +_java.time.Instant_, _java.time.Year_, and user-defined types that implement the _Serializable_ interface _)_; enums; entity types; collections of entity types; embeddable classes (see <>); collections of basic and embeddable types (see <>). @@ -1114,11 +1115,12 @@ public class MedicalHistory { === Basic Type -Basic type is any Java primitive type, wrapper of the primitive types, java.lang.String, -java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar, java.sql.Date, -java.sql.Time, java.sql.Timestamp, java.time.LocalDate, java.time.LocalTime, -java.time.LocalDateTime, java.time.OffsetTime, java.time.OffsetDateTime, byte[], Byte[], char[], -Character[], enum, any other type that implements Serializable. +A basic type is any Java primitive type, wrapper of the primitive types, java.lang.String, +java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar, +java.sql.Date, java.sql.Time, java.sql.Timestamp, java.time.LocalDate, java.time.LocalTime, +java.time.LocalDateTime, java.time.OffsetTime, java.time.OffsetDateTime, +java.time.Instant, java.time.Year, byte[], Byte[], char[], Character[], any enum type, +any other type that implements Serializable. === Embeddable Classes [[a487]] @@ -1281,8 +1283,9 @@ _java.util.UUID_, _java.util.Date_, _java.util.Calendar_, _java.sql.Date_, _java.sql.Time_, _java.sql.Timestamp_, _java.time.LocalDate_, _java.time.LocalTime_, _java.time.LocalDateTime_, _java.time.OffsetTime_, -_java.time.OffsetDateTime_, _byte[]_, _Byte[]_, _char[]_, -_Character[]_, enums, any other type that implements _Serializable_. +_java.time.OffsetDateTime_, _java.time.Instant_, _java.time.Year_ +_byte[]_, _Byte[]_, _char[]_, _Character[]_, enums, +any other type that implements _Serializable_. See <>, <>, <>, and <>. It is an error if no annotation is present diff --git a/spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc b/spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc index 76a39bb9..0717c943 100644 --- a/spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc +++ b/spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc @@ -538,16 +538,25 @@ _java.util.UUID_, _java.util.Date_, _java.util.Calendar_, _java.sql.Date_, _java.sql.Time_, _java.sql.Timestamp_, _java.time.LocalDate_, _java.time.LocalTime_, _java.time.LocalDateTime_, _java.time.OffsetTime_, _java.time.OffsetDateTime_, +_java.time.Instant_ and _java.time.Year_, _byte[]_, _Byte[]_, _char[]_, _Character[]_, enums, and any other type -that implements _Serializable_.footnote:[Mapping of -java.time.LocalDate, java.time.LocalTime, java.time.LocalDateTime, -java.time.OffsetTime, and java.time.OffsetDateTime types to columns -other than those supported by the mappings defined by Appendix B of the -JDBC 4.2 specification is not required to be supported by the -persistence provider beyond the support required for other serializable -types. See <>.] As described in <>, the use of the _Basic_ -annotation is optional for persistent fields and properties of these -types. If the _Basic_ annotation is not specified for such a field or +that implements _Serializable_. + +For the types listed above, the persistence provider must support mappings +to the column types listed in tables B-2 and B-4 of Appendix B of the +JDBC 4.3 specification. See <>. In addition, the provider must +support mapping: + +- _java.time.Instant_ to the JDBC _TIMESTAMP_ type, +- _java.time.Year_ to the JDBC _INTEGER_ and _SMALLINT_ types, +- _java.math.BigInteger_ and _java.math.BigDecimal_ to the JDBC _NUMERIC_ and _DECIMAL_ types, +- _java.util.UUID_ to the JDBC _CHAR_ and _VARCHAR_ types, and +- _char[]_ to the JDBC _CHAR_, _NCHAR_, _VARCHAR_, _NVARCHAR_, _LONGVARCHAR_, +and _LONGNVARCHAR_ types. + +As described in <>, the use of the _Basic_ +annotation is optional for persistent fields and properties of the +types listed above. If the _Basic_ annotation is not specified for such a field or property, the default values of the _Basic_ annotation will apply. [source,java] diff --git a/spec/src/main/asciidoc/related-documents.adoc b/spec/src/main/asciidoc/related-documents.adoc index 461ad61f..1a57f89e 100644 --- a/spec/src/main/asciidoc/related-documents.adoc +++ b/spec/src/main/asciidoc/related-documents.adoc @@ -7,7 +7,7 @@ - [[[a19493,1]]] Jakarta Persistence, v. 2.2. _https://jakarta.ee/specifications/persistence/2.2/_. - [[[a19494,2]]] SQL 2003, Part 2, Foundation (SQL/Foundation). ISO/IEC 9075-2:2003. -- [[[a19496,3]]] JDBC 4.2 Specification. http://jcp.org/en/jsr/detail?id=221. +- [[[a19496,3]]] JDBC 4.3 Specification. http://jcp.org/en/jsr/detail?id=221. - [[[a19497,4]]] Enterprise JavaBeans, v. 2.1. - [[[a19498,5]]] Jakarta Bean Validation, v. 3.0. _https://jakarta.ee/specifications/bean-validation/3.0/_. - [[[a19499,6]]] Jakarta EE Platform, v. 9.0. _https://jakarta.ee/specifications/platform/9/_.