Skip to content

Commit 979990f

Browse files
committed
add a CAUTION about overuse of inheritance to docs
1 parent ced5314 commit 979990f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

documentation/src/main/asciidoc/introduction/Mapping.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ is a bad idea, since it's impossible to create a foreign key constraint that tar
168168
// Hibernate doesn't support mixing ``InheritanceType``s within a single entity hierarchy.
169169
// However, it's possible to emulate a mix of `SINGLE_TABLE` and `JOINED` inheritance using the `@SecondaryTable` annotation.
170170

171+
[CAUTION]
172+
====
173+
It's quite easy to overuse inheritance.
174+
We've occasionally seen extreme cases where a `JOINED` inheritance hierarchy includes _hundreds_ of entities, spanning hundreds of tables.
175+
Efficiently querying such a hierarchy is an almost impossible task for Hibernate.
176+
Fortunately, a `JOINED` inheritance relationship can always be remodeled as a <<one-to-one-pk,one-to-one association>>, allowing much more efficient queries.
177+
In general, a single entity inheritance hierarchy should never span more than a few tables, including secondary tables.
178+
====
179+
171180
[[table-mappings]]
172181
=== Mapping to tables
173182

0 commit comments

Comments
 (0)