From 849c4d21f63500b8a0bf8f5d47a4523732db37fa Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Mon, 28 Mar 2016 13:35:37 +0300 Subject: [PATCH] Document available Hibernate configurations --- .../userguide/Hibernate_User_Guide.adoc | 1 + .../userguide/appendices/Configurations.adoc | 677 ++++++++++++++++++ .../chapters/bootstrap/Bootstrap.adoc | 7 +- 3 files changed, 684 insertions(+), 1 deletion(-) create mode 100644 documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc diff --git a/documentation/src/main/asciidoc/userguide/Hibernate_User_Guide.adoc b/documentation/src/main/asciidoc/userguide/Hibernate_User_Guide.adoc index 0bb11342f4..50bcf377c6 100644 --- a/documentation/src/main/asciidoc/userguide/Hibernate_User_Guide.adoc +++ b/documentation/src/main/asciidoc/userguide/Hibernate_User_Guide.adoc @@ -29,6 +29,7 @@ include::chapters/osgi/OSGi.adoc[] include::chapters/envers/Envers.adoc[] include::chapters/portability/Portability.adoc[] +include::appendices/Configurations.adoc[] include::appendices/Legacy_Bootstrap.adoc[] include::appendices/Legacy_DomainModel.adoc[] include::appendices/Legacy_Criteria.adoc[] diff --git a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc new file mode 100644 index 0000000000..25a6f33d10 --- /dev/null +++ b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc @@ -0,0 +1,677 @@ +[[configurations]] +== Configurations + +[[configurations-strategy]] +=== Strategy configurations + +Many configuration settings define pluggable strategies that Hibernate uses for various purposes. +The configuration of many of these strategy type settings accept definition in various forms. +The documentation of such configuration settings refer here. +The types of forms available in such cases include: + +short name (if defined):: + Certain built-in strategy implementations have a corresponding short name. +strategy instance:: + An instance of the strategy implementation to use can be specified +strategy Class reference:: + A `java.lang.Class` reference of the strategy implementation to use +strategy Class name:: + The class name (`java.lang.String`) of the strategy implementation to use + +[[configurations-general]] +=== General Configuration + +[width="100%",cols="20%,20%,60%",] +|=================================================================================================================================================================================================================================================================== +|Property |Example |Purpose +|`hibernate.dialect` | `org.hibernate.dialect. +PostgreSQL94Dialect` | +The classname of a Hibernate `org.hibernate.dialect.Dialect` from which Hibernate can generate SQL optimized for a particular relational database. + +In most cases Hibernate can choose the correct `org.hibernate.dialect.Dialect` implementation based on the JDBC metadata returned by the JDBC driver. + +|`hibernate.current_session_context_class` |`jta`, `thread`, `managed`, or a custom class implementing `org.hibernate.context.spi. +CurrentSessionContext` | + +Supply a custom strategy for the scoping of the _current_ `Session`. + +The definition of what exactly _current_ means is controlled by the `org.hibernate.context.spi.CurrentSessionContext` implementation in use. + +Note that for backwards compatibility, if a `org.hibernate.context.spi.CurrentSessionContext` is not configured but JTA is configured this will default to the `org.hibernate.context.internal.JTASessionContext`. + +|=================================================================================================================================================================================================================================================================== + +[[configurations-database-connection]] +=== Database connection properties + +[width="100%",cols="20%,20%,60%",] +|=================================================================================================================================================================================================================================== +|Property |Example |Purpose +|`hibernate.connection.driver_class` | `org.postgresql.Driver` | Names the JDBC `Driver` class name. +|`hibernate.connection.url` | `jdbc:postgresql:hibernate_orm_test` | Names the JDBC connection URL. +|`hibernate.connection.username` | | Names the JDBC connection user name. +|`hibernate.connection.password` | | Names the JDBC connection password. +|`hibernate.connection.isolation` | `REPEATABLE_READ` or +`Connection.TRANSACTION_REPEATABLE_READ` | Names the JDBC connection transaction isolation level. +|`hibernate.connection.autocommit` | `true` or `false` (default value) | Names the JDBC connection autocommit mode. +|`hibernate.connection.pool_size` | 20 | Maximum number of connections for the built-in Hibernate connection pool. +|`hibernate.connection.datasource` | | + +Either a `javax.sql.DataSource` instance or a JNDI name under which to locate the `DataSource`. + +For JNDI names, ses also `hibernate.jndi.class`, `hibernate.jndi.url`, `hibernate.jndi`. + +|`hibernate.connection` | | Names a prefix used to define arbitrary JDBC connection properties. These properties are passed along to the JDBC provider when creating a connection. +|`hibernate.connection.provider_class` | `org.hibernate.hikaricp.internal. +HikariCPConnectionProvider` a| + +Names the `org.hibernate.engine.jdbc.connections.spi.ConnectionProvider` to use for obtaining JDBC connections. + +Can reference: + +* an instance of `ConnectionProvider` +* a `Class` or the `ClassLoader` instance Hibernate should use for class-loading and resource-lookups. +|`hibernate.classLoader.application` | |Names the `ClassLoader` used to load user application classes. +|`hibernate.classLoader.resources` | |Names the `ClassLoader` Hibernate should use to perform resource loading. +|`hibernate.classLoader.hibernate` | |Names the `ClassLoader` responsible for loading Hibernate classes. By default this is the `ClassLoader` that loaded this class. +|`hibernate.classLoader.environment` | |Names the `ClassLoader` used when Hibernate is unable to locates classes on the `hibernate.classLoader.application` or `hibernate.classLoader.hibernate`. +|===================================================================================================================================================================================================================================================== + +[[configurations-misc]] +=== Miscellaneous properties + +[width="100%",cols="20%,20%,60%",] +|===================================================================================================================================================================================================================================================== +|Property |Example |Purpose +|`hibernate.dialect_resolvers` | | Names any additional `org.hibernate.engine.jdbc.dialect.spi.DialectResolver` implementations to register with the standard `org.hibernate.engine.jdbc.dialect.spi.DialectFactory` +|`hibernate.session_factory_name` |A JNDI name | + +Setting used to name the Hibernate `SessionFactory`. +Naming the `SessionFactory` allows for it to be properly serialized across JVMs as long as the same name is used on each JVM. + +If `hibernate.session_factory_name_is_jndi` is set to `true`, this is also the name under which the `SessionFactory` is bound into JNDI on startup and from which it can be obtained from JNDI. + +|`hibernate.session_factory_name_is_jndi` |`true` (default value) | + +Does the value defined by `hibernate.session_factory_name` represent a JNDI namespace into which the `org.hibernate.SessionFactory` should be bound and made accessible? + +Defaults to `true` for backwards compatibility. Set this to `false` if naming a SessionFactory is needed for serialization purposes, but no writable JNDI context exists in the runtime environment or if the user simply does not want JNDI to be used. + +|`hibernate.bytecode.use_reflection_optimizer`| `true` or `false` (default value) | Should we use reflection optimization? The reflection optimizer implements the `org.hibernate.bytecode.spi.ReflectionOptimizer` interface and improves entity instantiation and property getter/setter calls. +|===================================================================================================================================================================================================================================================== diff --git a/documentation/src/main/asciidoc/userguide/chapters/bootstrap/Bootstrap.adoc b/documentation/src/main/asciidoc/userguide/chapters/bootstrap/Bootstrap.adoc index 6f4f29692c..7d7846aed7 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/bootstrap/Bootstrap.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/bootstrap/Bootstrap.adoc @@ -13,6 +13,11 @@ Those will be covered in each specific more-relevant chapters later on. Instead we focus here on the API calls needed to perform the bootstrapping. ==== +[TIP] +==== +During the bootstrap process, you might want to customize Hibernate behavior so make sure you check the <> section as well. +==== + [[bootstrap-native]] === Native Bootstrapping @@ -235,4 +240,4 @@ include::{sourcedir}/BootstrapTest.java[tags=bootstrap-native-EntityManagerFacto ---- ==== -The `integrationSettings` allows the application develoepr to customize the bootstrapping process by specifying different `hibernate.integrator_provider` or `hibernate.strategy_registration_provider` integration providers. +The `integrationSettings` allows the application develoepr to customize the bootstrapping process by specifying different `hibernate.integrator_provider` or `hibernate.strategy_registration_provider` integration providers. \ No newline at end of file