Appendix A. Reference Material A.1. Hibernate Properties Table A.1. Connection Properties Configurable in the persistence.xml File Property Name Value Description javax.persistence.jdbc.driver org.hsqldb.jdbcDriver The class name of the JDBC driver to be used. javax.persistence.jdbc.user sa The username. javax.persistence.jdbc.password The password. javax.persistence.jdbc.url jdbc:hsqldb:. The JDBC connection URL. Table A.2. Hibernate Configuration Properties Property Name Description hibernate.dialect The class name of a Hibernate org.hibernate.dialect.Dialect . Allows Hibernate to generate SQL optimized for a particular relational database. In most cases Hibernate will be able to choose the correct org.hibernate.dialect.Dialect implementation, based on the JDBC metadata returned by the JDBC driver. hibernate.show_sql Boolean. Writes all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL to debug . hibernate.format_sql Boolean. Pretty print the SQL in the log and console. hibernate.default_schema Qualify unqualified table names with the given schema/tablespace in generated SQL. hibernate.default_catalog Qualifies unqualified table names with the given catalog in generated SQL. hibernate.session_factory_name The org.hibernate.SessionFactory will be automatically bound to this name in Java Naming and Directory Interface after it has been created. For example, jndi/composite/name .Jpa hibernate.max_fetch_depth Sets a maximum depth for the outer join fetch tree for single-ended associations (one-to-one, many-to-one). A 0 disables default outer join fetching. The recommended value is between 0 and 3 . hibernate.default_batch_fetch_size Sets a default size for Hibernate batch fetching of associations. The recommended values are 4 , 8 , and 16 . hibernate.default_entity_mode Sets a default mode for entity representation for all sessions opened from this SessionFactory . Values include: dynamic-map , dom4j , pojo . hibernate.order_updates Boolean. Forces Hibernate to order SQL updates by the primary key value of the items being updated. This will result in fewer transaction deadlocks in highly concurrent systems. hibernate.generate_statistics Boolean. If enabled, Hibernate will collect statistics useful for performance tuning. hibernate.use_identifier_rollback Boolean. If enabled, generated identifier properties will be reset to default values when objects are deleted. hibernate.use_sql_comments Boolean. If turned on, Hibernate will generate comments inside the SQL, for easier debugging. Default value is false . hibernate.id.new_generator_mappings Boolean. This property is relevant when using @GeneratedValue. It indicates whether or not the new IdentifierGenerator implementations are used for javax.persistence.GenerationType.AUTO, javax.persistence.GenerationType.TABLE and javax.persistence.GenerationType.SEQUENCE. Default value is true . hibernate.ejb.naming_strategy Chooses the org.hibernate.cfg.NamingStrategy implementation when using Hibernate EntityManager. hibernate.ejb.naming_strategy is no longer supported in Hibernate 5.0. If used, a deprecation message will be logged indicating that it is no longer supported and has been removed in favor of the split ImplicitNamingStrategy and PhysicalNamingStrategy. If the application does not use EntityManager, follow the instructions here to configure the NamingStrategy: Hibernate Reference Documentation - Naming Strategies . For an example on native bootstrapping using MetadataBuilder and applying the implicit naming strategy, see http://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html#bootstrap-native-metadata in the Hibernate 5.0 documentation. The physical naming strategy can be applied by using MetadataBuilder.applyPhysicalNamingStrategy() . For further details on org.hibernate.boot.MetadataBuilder , see https://docs.jboss.org/hibernate/orm/5.0/javadocs/ . hibernate.implicit_naming_strategy Specifies the org.hibernate.boot.model.naming.ImplicitNamingStrategy class to be used. hibernate.implicit_naming_strategy can also be used to configure a custom class that implements ImplicitNamingStrategy. Following short names are defined for this setting: default - ImplicitNamingStrategyJpaCompliantImpl jpa - ImplicitNamingStrategyJpaCompliantImpl legacy-jpa - ImplicitNamingStrategyLegacyJpaImpl legacy-hbm - ImplicitNamingStrategyLegacyHbmImpl component-path - ImplicitNamingStrategyComponentPathImpl The default setting is defined by the ImplicitNamingStrategy in the default short name. If the default setting is empty, the fallback is to use ImplicitNamingStrategyJpaCompliantImpl . hibernate.physical_naming_strategy Pluggable strategy contract for applying physical naming rules for database object names. Specifies the PhysicalNamingStrategy class to be used. PhysicalNamingStrategyStandardImpl is used by default. hibernate.physical_naming_strategy can also be used to configure a custom class that implements PhysicalNamingStrategy. Important For hibernate.id.new_generator_mappings , new applications should keep the default value of true . Existing applications that used Hibernate 3.3.x may need to change it to false to continue using a sequence object or table based generator, and maintain backward compatibility. Table A.3. Hibernate JDBC and Connection Properties Property Name Description hibernate.jdbc.fetch_size A non-zero value that determines the JDBC fetch size (calls Statement.setFetchSize() ). hibernate.jdbc.batch_size A non-zero value enables use of JDBC2 batch updates by Hibernate. The recommended values are between 5 and 30 . hibernate.jdbc.batch_versioned_data Boolean. Set this property to true if the JDBC driver returns correct row counts from executeBatch() . Hibernate will then use batched DML for automatically versioned data. Default value is to false . hibernate.jdbc.factory_class Select a custom org.hibernate.jdbc.Batcher. Most applications will not need this configuration property. hibernate.jdbc.use_scrollable_resultset Boolean. Enables use of JDBC2 scrollable resultsets by Hibernate. This property is only necessary when using user-supplied JDBC connections. Hibernate uses connection metadata otherwise. hibernate.jdbc.use_streams_for_binary Boolean. This is a system-level property. Use streams when writing/reading binary or serializable types to/from JDBC. hibernate.jdbc.use_get_generated_keys Boolean. Enables use of PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+. Set to false if JDBC driver has problems with the Hibernate identifier generators. By default, it tries to determine the driver capabilities using connection metadata. hibernate.connection.provider_class The class name of a custom org.hibernate.connection.ConnectionProvider which provides JDBC connections to Hibernate. hibernate.connection.isolation Sets the JDBC transaction isolation level. Check java.sql.Connection for meaningful values, but note that most databases do not support all isolation levels and some define additional, non-standard isolations. Standard values are 1, 2, 4, 8 . hibernate.connection.autocommit Boolean. This property is not recommended for use. Enables autocommit for JDBC pooled connections. hibernate.connection.release_mode Specifies when Hibernate should release JDBC connections. By default, a JDBC connection is held until the session is explicitly closed or disconnected. The default value auto chooses after_statement for the Jakarta Transactions and CMT transaction strategies, and after_transaction for the JDBC transaction strategy. Available values are auto (default), on_close, after_transaction , after_statement . This setting only affects the session returned from SessionFactory.openSession . For the session obtained through SessionFactory.getCurrentSession , the CurrentSessionContext implementation configured for use controls the connection release mode for that session. hibernate.connection. <propertyName> Pass the JDBC property <propertyName> to DriverManager.getConnection() . hibernate.jndi. <propertyName> Pass the property <propertyName> to the Java Naming and Directory Interface InitialContextFactory . Table A.4. Hibernate Cache Properties Property Name Description hibernate.cache.region.factory_class The class name of a custom CacheProvider . hibernate.cache.use_minimal_puts Boolean. Optimizes second-level cache operation to minimize writes, at the cost of more frequent reads. This setting is most useful for clustered caches and, in Hibernate3, is enabled by default for clustered cache implementations. hibernate.cache.use_query_cache Boolean. Enables the query cache. Individual queries still have to be set cacheable. hibernate.cache.use_second_level_cache Boolean. Used to completely disable the second level cache, which is enabled by default for classes that specify a <cache> mapping. hibernate.cache.query_cache_factory The class name of a custom QueryCache interface. The default value is the built-in StandardQueryCache . hibernate.cache.region_prefix A prefix to use for second-level cache region names. hibernate.cache.use_structured_entries Boolean. Forces Hibernate to store data in the second-level cache in a more human-friendly format. hibernate.cache.default_cache_concurrency_strategy Setting used to give the name of the default org.hibernate.annotations.CacheConcurrencyStrategy to use when either @Cacheable or @Cache is used. @Cache(strategy="..") is used to override this default. Table A.5. Hibernate Transaction Properties Property Name Description hibernate.transaction.factory_class The classname of a TransactionFactory to use with Hibernate Transaction API. Defaults to JDBCTransactionFactory ). jta.UserTransaction A Java Naming and Directory Interface name used by JTATransactionFactory to obtain the Jakarta Transactions UserTransaction from the application server. hibernate.transaction.manager_lookup_class The classname of a TransactionManagerLookup . It is required when JVM-level caching is enabled or when using hilo generator in a Jakarta Transactions environment. hibernate.transaction.flush_before_completion Boolean. If enabled, the session will be automatically flushed during the before completion phase of the transaction. Built-in and automatic session context management is preferred. hibernate.transaction.auto_close_session Boolean. If enabled, the session will be automatically closed during the after completion phase of the transaction. Built-in and automatic session context management is preferred. Table A.6. Miscellaneous Hibernate Properties Property Name Description hibernate.current_session_context_class Supply a custom strategy for the scoping of the "current" Session . Values include jta , thread , managed , custom.Class . hibernate.query.factory_class Chooses the HQL parser implementation: org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory or org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory . hibernate.query.substitutions Used to map from tokens in Hibernate queries to SQL tokens (tokens might be function or literal names). For example, hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC . hibernate.query.conventional_java_constants Indicates whether the Java constants follow the Java naming conventions or not. Default is false . Existing applications may set it to true only if conventional Java constants are being used in the applications. Setting this to true has significant performance improvement because then Hibernate can determine if an alias should be treated as a Java constant simply by checking if the alias follows the Java naming conventions. When this property is set to false , Hibernate determines an alias should be treated as a Java constant by attempting to load the alias as a class, which is an overhead for the application. If alias fails to load as a class, then Hibernate treats the alias as a Java constant. hibernate.hbm2ddl.auto Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop , the database schema will be dropped when the SessionFactory is closed explicitly. Property value options are validate , update , create , create-drop hibernate.hbm2ddl.import_files Comma-separated names of the optional files containing SQL DML statements executed during the SessionFactory creation. This is useful for testing or demonstrating. For example, by adding INSERT statements, the database can be populated with a minimal set of data when it is deployed. An example value is /humans.sql,/dogs.sql . File order matters, as the statements of a given file are executed before the statements of the following files. These statements are only executed if the schema is created, for example if hibernate.hbm2ddl.auto is set to create or create-drop . hibernate.hbm2ddl.import_files_sql_extractor The classname of a custom ImportSqlCommandExtractor. Defaults to the built-in SingleLineSqlCommandExtractor. This is useful for implementing a dedicated parser that extracts a single SQL statement from each import file. Hibernate also provides MultipleLinesSqlCommandExtractor, which supports instructions/comments and quoted strings spread over multiple lines (mandatory semicolon at the end of each statement). hibernate.bytecode.use_reflection_optimizer Boolean. This is a system-level property, which cannot be set in the hibernate.cfg.xml file. Enables the use of bytecode manipulation instead of runtime reflection. Reflection can sometimes be useful when troubleshooting. Hibernate always requires either cglib or javassist even if the optimizer is turned off. hibernate.bytecode.provider Both javassist or cglib can be used as byte manipulation engines. The default is javassist . The value is either javassist or cglib . Table A.7. Hibernate SQL Dialects (hibernate.dialect) RDBMS Dialect DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS390 org.hibernate.dialect.DB2390Dialect Firebird org.hibernate.dialect.FirebirdDialect FrontBase org.hibernate.dialect.FrontbaseDialect H2 Database org.hibernate.dialect.H2Dialect HypersonicSQL org.hibernate.dialect.HSQLDialect Informix org.hibernate.dialect.InformixDialect Ingres org.hibernate.dialect.IngresDialect Interbase org.hibernate.dialect.InterbaseDialect MariaDB 10 org.hibernate.dialect.MariaDB10Dialect MariaDB Galera Cluster 10 org.hibernate.dialect.MariaDB10Dialect Mckoi SQL org.hibernate.dialect.MckoiDialect Microsoft SQL Server 2000 org.hibernate.dialect.SQLServerDialect Microsoft SQL Server 2005 org.hibernate.dialect.SQLServer2005Dialect Microsoft SQL Server 2008 org.hibernate.dialect.SQLServer2008Dialect Microsoft SQL Server 2012 org.hibernate.dialect.SQLServer2012Dialect Microsoft SQL Server 2014 org.hibernate.dialect.SQLServer2012Dialect Microsoft SQL Server 2016 org.hibernate.dialect.SQLServer2012Dialect MySQL5 org.hibernate.dialect.MySQL5Dialect MySQL5.5 org.hibernate.dialect.MySQL55Dialect MySQL5.7 org.hibernate.dialect.MySQL57Dialect Oracle (any version) org.hibernate.dialect.OracleDialect Oracle 9i org.hibernate.dialect.Oracle9iDialect Oracle 10g org.hibernate.dialect.Oracle10gDialect Oracle 11g org.hibernate.dialect.Oracle10gDialect Oracle 12c org.hibernate.dialect.Oracle12cDialect Pointbase org.hibernate.dialect.PointbaseDialect PostgreSQL org.hibernate.dialect.PostgreSQLDialect PostgreSQL 9.2 org.hibernate.dialect.PostgreSQL9Dialect PostgreSQL 9.3 org.hibernate.dialect.PostgreSQL9Dialect PostgreSQL 9.4 org.hibernate.dialect.PostgreSQL94Dialect Postgres Plus Advanced Server org.hibernate.dialect.PostgresPlusDialect Progress org.hibernate.dialect.ProgressDialect SAP DB org.hibernate.dialect.SAPDBDialect Sybase org.hibernate.dialect.SybaseASE15Dialect Sybase 15.7 org.hibernate.dialect.SybaseASE157Dialect Sybase 16 org.hibernate.dialect.SybaseASE157Dialect Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect Important The hibernate.dialect property should be set to the correct org.hibernate.dialect.Dialect subclass for the application database. If a dialect is specified, Hibernate will use sensible defaults for some of the other properties. This means that they do not have to be specified manually. Revised on 2024-01-17 05:24:48 UTC

Commands: