From fd5c52bce417026936a15e83c4b355b73040f70b Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 13 Jan 2025 19:17:17 +0100 Subject: [PATCH 1/2] add a WARNING about @ManyToMany(fetch=EAGER) --- .../src/main/asciidoc/introduction/Entities.adoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/documentation/src/main/asciidoc/introduction/Entities.adoc b/documentation/src/main/asciidoc/introduction/Entities.adoc index d9ace369c494..dd9b9d84ed63 100644 --- a/documentation/src/main/asciidoc/introduction/Entities.adoc +++ b/documentation/src/main/asciidoc/introduction/Entities.adoc @@ -1422,6 +1422,14 @@ However, as before, the order of the elements is not persistent. That is, the collection is a _bag_, not a set. ==== +[WARNING] +==== +We don't usually map collections with `fetch=EAGER`, since that usually leads to poor performance and fetching of unnecessary data. +But this is especially clear in the case of many-to-many associations. +We don't much employ the word "never" when it comes to object/relational mappings, but here we will: +**never** write `@ManyToMany(fetch=EAGER)` unless you're deliberately looking for trouble. +==== + [[collections]] === Collections of basic values and embeddable objects From 381e795b0499e4b14e025dfde76cd217bef84518 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 13 Jan 2025 19:17:30 +0100 Subject: [PATCH 2/2] very minor change to jdoc --- .../java/org/hibernate/type/descriptor/WrapperOptions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java index a2f690225364..64056b501a1f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java @@ -58,7 +58,7 @@ default boolean useStreamForLobBinding() { /** * The JDBC {@link java.sql.Types type code} used to bind a null boolean value. * - * @see org.hibernate.cfg.AvailableSettings#PREFERRED_BOOLEAN_JDBC_TYPE + * @see org.hibernate.cfg.MappingSettings#PREFERRED_BOOLEAN_JDBC_TYPE * @see org.hibernate.dialect.Dialect#getPreferredSqlTypeCodeForBoolean() */ default int getPreferredSqlTypeCodeForBoolean() { @@ -70,7 +70,7 @@ default int getPreferredSqlTypeCodeForBoolean() { * * @return The LOB creator * - * @see org.hibernate.cfg.AvailableSettings#NON_CONTEXTUAL_LOB_CREATION + * @see org.hibernate.cfg.JdbcSettings#NON_CONTEXTUAL_LOB_CREATION * @see org.hibernate.dialect.Dialect#getDefaultNonContextualLobCreation() */ default LobCreator getLobCreator() { @@ -98,7 +98,7 @@ default LobCreator getLobCreator() { * * @return the JDBC {@link TimeZone}, or null if no JDBC timezone was explicitly set * - * @see org.hibernate.cfg.AvailableSettings#JDBC_TIME_ZONE + * @see org.hibernate.cfg.JdbcSettings#JDBC_TIME_ZONE */ default TimeZone getJdbcTimeZone() { return getSessionFactory().getSessionFactoryOptions().getJdbcTimeZone();