Skip to content

Commit d5e829d

Browse files
committed
add section on quoted identifiers to doc
Signed-off-by: Gavin King <[email protected]>
1 parent 5253875 commit d5e829d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,32 @@ Writing your own `PhysicalNamingStrategy` and/or `ImplicitNamingStrategy` is an
494494
We'll have more to say about them in <<naming-strategies>>.
495495
====
496496

497+
[[quoted-identifiers]]
498+
=== Quoting SQL identifiers
499+
500+
By default, Hibernate never quotes SQL table and column names in generated SQL.
501+
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.
502+
503+
The following settings enable automatic quoting:
504+
505+
.Settings for identifier quoting
506+
[%breakable,cols="35,~"]
507+
|===
508+
| Configuration property name | Purpose
509+
510+
| `hibernate.auto_quote_keyword` | Automatically quote any identifier which is a SQL keyword
511+
| `hibernate.globally_quoted_identifiers` | Automatically quote every identifier
512+
|===
513+
514+
Note that `hibernate.globally_quoted_identifiers` is a synonym for `<delimited-identifiers/>` in <<configuration-jpa,`persistence.xml`>>.
515+
We don't recommend the use of global identifier quoting, and in fact these settings are rarely used.
516+
517+
[TIP]
518+
====
519+
A better alternative is to explicitly quote table and column names where necessary, by writing `@Table(name="\"View\")` or `@Column(name="\"number\"")`.
520+
Since that's kinda ugly, Hibernate lets us use a backtick as the quote character instead of the double quote.
521+
====
522+
497523
[[nationalized-chars]]
498524
=== Nationalized character data in SQL Server
499525

0 commit comments

Comments
 (0)