From 02b551464d8b1c538c939a3ccb862f4d3d33073f Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 11 May 2023 11:54:23 +0200 Subject: [PATCH] mention constraints which Hibernate doesn't actually create due to bug --- documentation/src/main/asciidoc/introduction/Entities.adoc | 2 +- documentation/src/main/asciidoc/introduction/Mapping.adoc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/documentation/src/main/asciidoc/introduction/Entities.adoc b/documentation/src/main/asciidoc/introduction/Entities.adoc index e4a96126ee..fad1d02272 100644 --- a/documentation/src/main/asciidoc/introduction/Entities.adoc +++ b/documentation/src/main/asciidoc/introduction/Entities.adoc @@ -927,7 +927,7 @@ Collection books; [NOTE] .`Set`, `List`, or `Collection`? ==== -A one to many association mapped to a foreign key can never contain duplicate elements, so `Set` seems like the most semantically correct Java collection type to use here, and so that's the conventional practice in the Hibernate community. +A one-to-many association mapped to a foreign key can never contain duplicate elements, so `Set` seems like the most semantically correct Java collection type to use here, and so that's the conventional practice in the Hibernate community. The catch associated with using a set is that we must carefully ensure that `Book` has a high-quality implementation of <>. Now, that's not necessarily a bad thing, since a quality `equals()` is independently useful. diff --git a/documentation/src/main/asciidoc/introduction/Mapping.adoc b/documentation/src/main/asciidoc/introduction/Mapping.adoc index 6cf560b1b0..0dfcc6e9f0 100644 --- a/documentation/src/main/asciidoc/introduction/Mapping.adoc +++ b/documentation/src/main/asciidoc/introduction/Mapping.adoc @@ -264,6 +264,8 @@ class Book { } ---- +Here, there should be a `UNIQUE` constraint on one of the columns of the association table. + [source,java] ---- @Entity @@ -276,6 +278,8 @@ class Author { } ---- +Here, there should be a `UNIQUE` constraint on _both_ columns of the association table. + .`@JoinTable` annotation members [cols=",8"] |===