Skip to content

Commit

Permalink
add support for Instant and Year and clarify JDBC mappings for basic …
Browse files Browse the repository at this point in the history
…types

see jakartaee#163
  • Loading branch information
gavinking committed Aug 9, 2023
1 parent 4daf494 commit 8da2157
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
2 changes: 2 additions & 0 deletions spec/src/main/asciidoc/appendixes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
17 changes: 10 additions & 7 deletions spec/src/main/asciidoc/ch02-entities.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<a487>>); collections of basic and embeddable types (see <<a494>>).
Expand Down Expand Up @@ -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]]

Expand Down Expand Up @@ -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 <<a14205>>, <<a14719>>, <<a15087>>, and <<a16361>>.

It is an error if no annotation is present
Expand Down
27 changes: 18 additions & 9 deletions spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<a19496>>.] As described in <<a511>>, 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 <<a19496>>. 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 <<a511>>, 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]
Expand Down
2 changes: 1 addition & 1 deletion spec/src/main/asciidoc/related-documents.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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/_.
Expand Down

0 comments on commit 8da2157

Please sign in to comment.