Skip to content

Commit 697d820

Browse files
committed
add some documentation about date/time config settings
and also add some links
1 parent fe9a3cc commit 697d820

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

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

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ The following properties are very useful for minimizing the amount of informatio
481481
|===
482482
| Configuration property name | Purpose
483483

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
488488
|===
489489

490490
[TIP]
@@ -507,8 +507,8 @@ The following settings enable automatic quoting:
507507
|===
508508
| Configuration property name | Purpose
509509

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
512512
|===
513513

514514
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
532532
|===
533533
| Configuration property name | Purpose
534534

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`
536536
|===
537537

538538
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:
543543
Alternatively, you can configure SQL Server to use the UTF-8 enabled collation `_UTF8`.
544544
====
545545

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.
573+

0 commit comments

Comments
 (0)