mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
mention constraints which Hibernate doesn't actually create due to bug
This commit is contained in:
parent
1d3f4f47f1
commit
7fd70a0284
@ -927,7 +927,7 @@ Collection<Book> books;
|
|||||||
[NOTE]
|
[NOTE]
|
||||||
.`Set`, `List`, or `Collection`?
|
.`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 <<equals-and-hash>>.
|
The catch associated with using a set is that we must carefully ensure that `Book` has a high-quality implementation of <<equals-and-hash>>.
|
||||||
Now, that's not necessarily a bad thing, since a quality `equals()` is independently useful.
|
Now, that's not necessarily a bad thing, since a quality `equals()` is independently useful.
|
||||||
|
@ -264,6 +264,8 @@ class Book {
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
Here, there should be a `UNIQUE` constraint on one of the columns of the association table.
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Entity
|
@Entity
|
||||||
@ -276,6 +278,8 @@ class Author {
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
Here, there should be a `UNIQUE` constraint on _both_ columns of the association table.
|
||||||
|
|
||||||
.`@JoinTable` annotation members
|
.`@JoinTable` annotation members
|
||||||
[cols=",8"]
|
[cols=",8"]
|
||||||
|===
|
|===
|
||||||
|
Loading…
x
Reference in New Issue
Block a user