Skip to content

Commit

Permalink
spec UUID support
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed May 5, 2021
1 parent 1ae01ae commit b5d2afa
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
9 changes: 8 additions & 1 deletion api/src/main/java/jakarta/persistence/GenerationType.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ public enum GenerationType {
* Indicates that the persistence provider must assign
* primary keys for the entity using a database identity column.
*/
IDENTITY,
IDENTITY,

/**
* Indicates that the persistence provider must assign
* primary keys for the entity by generating a RFC 4122
* Universally Unique IDentifier.
*/
UUID,

/**
* Indicates that the persistence provider should pick an
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/resources/jakarta/persistence/orm_3_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1057,14 +1057,15 @@
<xsd:annotation>
<xsd:documentation>

public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
public enum GenerationType { TABLE, SEQUENCE, IDENTITY, UUID, AUTO };

</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="TABLE"/>
<xsd:enumeration value="SEQUENCE"/>
<xsd:enumeration value="IDENTITY"/>
<xsd:enumeration value="UUID"/>
<xsd:enumeration value="AUTO"/>
</xsd:restriction>
</xsd:simpleType>
Expand Down
36 changes: 18 additions & 18 deletions spec/src/main/asciidoc/ch02-entities.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,19 @@ accessor methods. However, portable applications must not override the
object/relational mapping metadata that applies to the persistent fields
or properties of entity superclasses.

The persistent fields or properties of an
entity may be of the following types: Java primitive types,
_java.lang.String_, other Java serializable types (including wrappers
of the primitive types, _java.math.BigInteger_, _java.math.BigDecimal_
, _java.util.Date_, _java.util.Calendarfootnote:[Note that an instance
of Calendar must be fully initialized for the type that it is mapped to.]_,
The persistent fields or properties of an entity may be of the following
types: Java primitive types, _java.lang.String_, other Java serializable
types (including wrappers of the primitive types, _java.math.BigInteger_,
_java.math.BigDecimal_, _java.util.UUD_, _java.util.Date_,
_java.util.Calendarfootnote:[Note that an instance of Calendar must be
fully initialized for the type that it is mapped to.]_,
_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_, 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>>).
_java.time.OffsetTime_, _java.time.OffsetDateTime_,
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>>).

Object/relational mapping metadata may be
specified to customize the object/relational mapping and the loading and
Expand Down Expand Up @@ -397,9 +397,9 @@ arise when mapping from legacy databases when the database key is
comprised of several columns. The _EmbeddedId_ or _IdClass_ annotation
is used to denote a composite primary key. See <<a14687>> and <<a14836>>.

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_;
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.UUID_;
_java.util.Date_; _java.sql.Date_; _java.math.BigDecimal_;
_java.math.BigInteger_.footnote:[In general, however,
approximate numeric types (e.g., floating point types) should never be
Expand Down Expand Up @@ -1259,11 +1259,11 @@ are applied in order:
the _Embeddable_ annotation, it is mapped in the same way as if the
field or property were annotated with the _Embedded_ annotation. See
<<a14634>> and <<a14672>>.
* If the type of the field or property is one
of the following, it is mapped in the same way as it would if it were
annotated as _Basic_: Java primitive types, wrappers of the primitive
types, _java.lang.String_, _java.math.BigInteger_,
_java.math.BigDecimal_, _java.util.Date_, _java.util.Calendar_,
* If the type of the field or property is one of the following, it is
mapped in the same way as it would if it were annotated as _Basic_:
Java primitive types, wrappers of the primitive types,
_java.lang.String_, _java.math.BigInteger_, _java.math.BigDecimal_,
_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_,
Expand Down
29 changes: 16 additions & 13 deletions spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,12 @@ of mapping to a database column. The _Basic_ annotation can be applied
to a persistent property or instance variable of any of the following
types: Java primitive types, wrappers 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[]_, enums, and any other type that
implements _Serializable_.footnote:[Mapping of
_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, 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
Expand Down Expand Up @@ -1825,7 +1825,7 @@ defined by the _GenerationType_ enum:

[source,java]
----
public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
public enum GenerationType { TABLE, SEQUENCE, IDENTITY, UUID, AUTO };
----

The _TABLE_ generator type value indicates
Expand All @@ -1840,13 +1840,17 @@ and IDENTITY are not portable across all databases.]
The further specification of table generators
and sequence generators is described in <<a16164>> and <<a16256>>.

The _UUID_ value indicates that the persistence provider should
assign an RFC 4122 Universally Unique IDentifier.

The _AUTO_ value indicates that the
persistence provider should pick an appropriate strategy for the
particular database. The _AUTO_ generation strategy may expect a
database resource to exist, or it may attempt to create one. A vendor
may provide documentation on how to create such resources in the event
that it does not support schema generation or cannot create the schema
resource at runtime.
resource at runtime. In the case of a field or property of type
_java.util.UUID_, the _AUTO_ strategy is equivalent to _UUID_.

This specification does not define the exact
behavior of these strategies.
Expand Down Expand Up @@ -1907,11 +1911,10 @@ The _Id_ annotation specifies the primary key
property or field of an entity. The _Id_ annotation may be applied in an
entity or mapped superclass.

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; _java.lang.String_;
_java.util.Date_; _java.sql.Date_; _java.math.BigDecimal_;
_java.math.BigInteger_footnote:[Primary keys using
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; _java.lang.String_; _java.util.UUID_; _java.util.Date_; _java.sql.Date_;
_java.math.BigDecimal_; _java.math.BigInteger_footnote:[Primary keys using
types other than these will not be portable. In general, floating point
types should never be used in primary keys.]. See <<a132>>.

Expand Down
3 changes: 2 additions & 1 deletion spec/src/main/asciidoc/ch12-xml-or-mapping-descriptor.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2014,14 +2014,15 @@ object/relational mapping schema for use with the persistence API.
<xsd:annotation>
<xsd:documentation>
public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
public enum GenerationType { TABLE, SEQUENCE, IDENTITY, UUID, AUTO };
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="TABLE"/>
<xsd:enumeration value="SEQUENCE"/>
<xsd:enumeration value="IDENTITY"/>
<xsd:enumeration value="UUID"/>
<xsd:enumeration value="AUTO"/>
</xsd:restriction>
</xsd:simpleType>
Expand Down

0 comments on commit b5d2afa

Please sign in to comment.