From 8945cad258cb667f970f300b4271f6a0031dba64 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Tue, 8 Aug 2023 14:41:37 +0200 Subject: [PATCH] revise restrictions on entity/embeddable classes and primary key classes see #380. --- spec/src/main/asciidoc/appendixes.adoc | 3 +++ spec/src/main/asciidoc/ch02-entities.adoc | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/src/main/asciidoc/appendixes.adoc b/spec/src/main/asciidoc/appendixes.adoc index 6e2ab49e..d90715ff 100644 --- a/spec/src/main/asciidoc/appendixes.adoc +++ b/spec/src/main/asciidoc/appendixes.adoc @@ -114,3 +114,6 @@ Added _concat()_ overload accepting list of expressions to _CriteriaBuilder_ Made the _name_ member of _TableGenerator_ and _SequenceGenerator_ optional +Entity and embeddable classes may now be static inner classes + +Primary key classes are no longer required to be public and serializable diff --git a/spec/src/main/asciidoc/ch02-entities.adoc b/spec/src/main/asciidoc/ch02-entities.adoc index 8f69147c..d0055b21 100644 --- a/spec/src/main/asciidoc/ch02-entities.adoc +++ b/spec/src/main/asciidoc/ch02-entities.adoc @@ -23,7 +23,7 @@ The entity class must have a no-arg constructor. The entity class may have other constructors as well. The no-arg constructor must be public or protected. -The entity class must be a top-level class. +The entity class must be a top-level class or a static inner class. An enum, record, or interface may not be designated as an entity. The entity class must not be final. No @@ -415,10 +415,10 @@ property, the temporal type should be specified as _DATE_. The following rules apply for composite primary keys: -- The primary key class may be a regular Java class, in which case it must -be public and must have a public no-arg constructor. Alternatively, it may -be a public Java record type, in which case it need not have a no-arg -constructor. +- The primary key class may be a non-abstract regular Java class with a +no-arg constructor. The no-arg constructor must be public or protected. +Alternatively, the primary key class may be any Java record type, in +which case it need not have a no-arg constructor. - The access type (field- or property-based access) of a primary key class is determined by the access type of the @@ -428,8 +428,6 @@ embedded id and a different access type is specified. See Section <>. - If property-based access is used, the properties of the primary key class must be public or protected. -- The primary key class must be serializable. - - The primary key class must define _equals_ and _hashCode_ methods. The semantics of value equality for these methods must be consistent with the database equality for the database @@ -1138,7 +1136,8 @@ for an embedded object is determined as described in <>. An embeddable class may be a regular Java class which adheres to the requirements specified in <> for entities, with the exception that -an embeddable class is not annotated as _Entity_. +an embeddable class is not annotated as _Entity_, and an embeddable +class may not be abstract. Alternatively, an embeddable class may be any Java record type.