You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/introduction/Configuration.adoc
+35-7Lines changed: 35 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -481,10 +481,10 @@ The following properties are very useful for minimizing the amount of informatio
481
481
|===
482
482
| Configuration property name | Purpose
483
483
484
-
| `hibernate.default_schema` | A default schema name for entities which do not explicitly declare one
485
-
| `hibernate.default_catalog` | A default catalog name for entities which do not explicitly declare one
486
-
| `hibernate.physical_naming_strategy` | A `PhysicalNamingStrategy` implementing your database naming standards
487
-
| `hibernate.implicit_naming_strategy` | An `ImplicitNamingStrategy` which specifies how "logical" names of relational objects should be inferred when no name is specified in annotations
484
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#DEFAULT_SCHEMA[`hibernate.default_schema`] | A default schema name for entities which do not explicitly declare one
485
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#DEFAULT_CATALOG[`hibernate.default_catalog`] | A default catalog name for entities which do not explicitly declare one
486
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#PHYSICAL_NAMING_STRATEGY[`hibernate.physical_naming_strategy`] | A `PhysicalNamingStrategy` implementing your database naming standards
487
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#IMPLICIT_NAMING_STRATEGY[`hibernate.implicit_naming_strategy`] | An `ImplicitNamingStrategy` which specifies how "logical" names of relational objects should be inferred when no name is specified in annotations
488
488
|===
489
489
490
490
[TIP]
@@ -507,8 +507,8 @@ The following settings enable automatic quoting:
507
507
|===
508
508
| Configuration property name | Purpose
509
509
510
-
| `hibernate.auto_quote_keyword` | Automatically quote any identifier which is a SQL keyword
511
-
| `hibernate.globally_quoted_identifiers` | Automatically quote every identifier
510
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#KEYWORD_AUTO_QUOTING_ENABLED[`hibernate.auto_quote_keyword`] | Automatically quote any identifier which is a SQL keyword
511
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#GLOBALLY_QUOTED_IDENTIFIERS[`hibernate.globally_quoted_identifiers`] | Automatically quote every identifier
512
512
|===
513
513
514
514
Note that `hibernate.globally_quoted_identifiers` is a synonym for `<delimited-identifiers/>` in <<configuration-jpa,`persistence.xml`>>.
@@ -532,7 +532,7 @@ So, if you're working with SQL Server, you might need to force Hibernate to use
532
532
|===
533
533
| Configuration property name | Purpose
534
534
535
-
| `hibernate.use_nationalized_character_data` | Use `nchar` and `nvarchar` instead of `char` and `varchar`
535
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#USE_NATIONALIZED_CHARACTER_DATA[`hibernate.use_nationalized_character_data`] | Use `nchar` and `nvarchar` instead of `char` and `varchar`
536
536
|===
537
537
538
538
On the other hand, if only _some_ columns store nationalized data, use the link:{doc-javadoc-url}org/hibernate/annotations/Nationalized.html[`@Nationalized`] annotation to indicate fields of your entities which map these columns.
@@ -543,3 +543,31 @@ On the other hand, if only _some_ columns store nationalized data, use the link:
543
543
Alternatively, you can configure SQL Server to use the UTF-8 enabled collation `_UTF8`.
544
544
====
545
545
546
+
[[datetime-jdbc]]
547
+
=== Date and time types and JDBC
548
+
549
+
By default, Hibernate handles date and time types defined by `java.time` by:
550
+
551
+
- converting `java.time` types to JDBC date/time types defined in `java.sql` when sending data to the database, and
552
+
- reading `java.sql` types from JDBC and then converting them to `java.time` types when retrieving data from the database.
553
+
554
+
This works best when the database server time zone agrees with JVM system time zone.
555
+
556
+
TIP: We therefore recommend setting things up so that the database server and the JVM agree on the same time zone. **Hint:** when in doubt, UTC quite a nice time zone.
557
+
558
+
There are two system configuration properties which influence this behavior:
559
+
560
+
.Settings for JDBC date/time handling
561
+
[%breakable,cols="35,~"]
562
+
|===
563
+
| Configuration property name | Purpose
564
+
565
+
| link:{doc-javadoc-url}org/hibernate/cfg/JdbcSettings.html#JDBC_TIME_ZONE[`hibernate.jdbc.time_zone`] | Use an explicit time zone when interacting with JDBC
566
+
| link:{doc-javadoc-url}org/hibernate/cfg/MappingSettings.html#JAVA_TIME_USE_DIRECT_JDBC[`hibernate.type.java_time_use_direct_jdbc`] | Read and write `java.time` types directly to and from JDBC
567
+
|===
568
+
569
+
You may set `hibernate.jdbc.time_zone` to the time zone of the database server if for some reason the JVM needs to operate in a different time zone.
570
+
We do not recommend this approach.
571
+
572
+
On the other hand, we would love to recommend the use of `hibernate.type.java_time_use_direct_jdbc`, but this option is still experimental for now, and does result in some subtle differences in behavior which might affect legacy programs using Hibernate.
0 commit comments