JPA 2.2 java.time type support for primary keys?

Jody Grassel
 
Edited

While going through the JPA 2.2 spec and reading the following:

2.4 Primary Keys and Entity Identity
...
A simple primary key or a field or property of a composite primary key should be one of the following types: any Java primitive type; any primitive wrapper type; java.lang.String; java.util.Date; java.sql.Date; java.math.BigDecimal; java.math.BigInteger.[9] If the primary key is a composite primary key derived from the primary key of another entity, the primary key may contain an attribute whose type is that of the primary key of the referenced entity as described in Section 2.4.1. Entities whose primary keys use types other than these will not be portable.  If generated primary keys are used, only integral types will be portable. If java.util.Date is used as a primary key field or property, the temporal type should be specified as DATE.

Above, I've bold-faced all text that referred to temporal types.  Note that there was no mention of the java.time types that support for was introduced in JPA 2.2.  Is this an intended omission -- that java.time types are not permissible for use with @Id properties, or is a correction in the spec's language needed? 

Looking at the @Id javadoc at https://javaee.github.io/javaee-spec/javadocs/javax/persistence/Id.html it states:

Specifies the primary key of an entity. The field or property to which the Id annotation is applied should be one of the following types: any Java primitive type; any primitive wrapper type; String; java.util.Date; java.sql.Date; java.math.BigDecimal; java.math.BigInteger.

Again, it only mentions java.util.Date and java.sql.Date, and no mention of the java.time types.

It also looks like @Version also omits any use of the new type, as on https://javaee.github.io/javaee-spec/javadocs/javax/persistence/Version.html it states:

The following types are supported for version properties: int, Integer, short, Short, long, Long, java.sql.Timestamp.

With no mention of at least java.time.LocalDateTime which maps via JDBC Appendix B to TIMESTAMP.

Join jpa-spec@javaee.groups.io to automatically receive all group messages.