From 61d6b1ce4a23bf5216e774e33a24231aee637127 Mon Sep 17 00:00:00 2001 From: Gavin Date: Mon, 15 May 2023 13:28:52 +0200 Subject: [PATCH] note about embeddable types and polymorphism --- documentation/src/main/asciidoc/introduction/Entities.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/documentation/src/main/asciidoc/introduction/Entities.adoc b/documentation/src/main/asciidoc/introduction/Entities.adoc index 74ef88c4d9..ea934ee280 100644 --- a/documentation/src/main/asciidoc/introduction/Entities.adoc +++ b/documentation/src/main/asciidoc/introduction/Entities.adoc @@ -865,6 +865,9 @@ JPA provides an `@Embedded` annotation to identify an attribute of an entity tha This annotation is completely optional, and so we don't usually use it. ==== +On the other hand a reference to an embeddable type is _never_ polymorphic. +One `@Embeddable` class `F` may inherit a second `@Embeddable` class `E`, but an attribute of type `E` will always refer to an instance of that concrete class `E`, never to an instance of `F`. + Usually, embeddable types are stored in a "flattened" format. Their attributes map columns of the table of their parent entity. Later, in <>, we'll see a couple of different options.