From 38fb68a57cf1f991270884b528c7f011bca2a5c3 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Fri, 29 Nov 2024 12:18:13 +0100 Subject: [PATCH] correctly describe automatic quoting in doc --- .../src/main/asciidoc/introduction/Configuration.adoc | 5 +++-- .../test/annotations/collectionelement/QueryTest.java | 11 +++++++++++ .../hibernate/orm/test/type/LocalDateTimeTest.java | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/documentation/src/main/asciidoc/introduction/Configuration.adoc b/documentation/src/main/asciidoc/introduction/Configuration.adoc index 3479293aaf..22a355462e 100644 --- a/documentation/src/main/asciidoc/introduction/Configuration.adoc +++ b/documentation/src/main/asciidoc/introduction/Configuration.adoc @@ -503,10 +503,11 @@ We'll have more to say about them in <>. [[quoted-identifiers]] === Quoting SQL identifiers -By default, Hibernate never quotes SQL table and column names in generated SQL. +By default, Hibernate never quotes a SQL table or column name in generated SQL when the name contains only alphanumeric characters. This behavior is usually much more convenient, especially when working with a legacy schema, since unquoted identifiers aren't case-sensitive, and so Hibernate doesn't need to know or care whether a column is named `NAME`, `name`, or `Name` on the database side. +On the other hand, any table or column name containing a punctuation character like `$` is automatically quoted by default. -The following settings enable automatic quoting: +The following settings enable additional automatic quoting: .Settings for identifier quoting [%breakable,cols="35,~"] diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/collectionelement/QueryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/collectionelement/QueryTest.java index f807b17707..1dff1059f2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/collectionelement/QueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/collectionelement/QueryTest.java @@ -59,4 +59,15 @@ public class QueryTest { } ); } + + @Test + @JiraKey(value = "HHH-14125" ) + public void testSelectElementCollectionProperty(SessionFactoryScope scope) { + // Selecting property directly works for basic types and associated entities, should also work for ElementCollection + scope.inSession( + session -> { + session.createQuery( "select e.someStrings from EntityWithAnElementCollection e" ).list(); + } + ); + } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/LocalDateTimeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/LocalDateTimeTest.java index 62b63034d3..a09636e347 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/LocalDateTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/LocalDateTimeTest.java @@ -98,6 +98,7 @@ public class LocalDateTimeTest extends AbstractJavaTimeTypeTest