Property name
Use
Hibernate.dialect
A hibernate dialect class name allows hibernate to generate optimized SQL for a particular relational database. Value full.classname.of.Dialect
Hibernate.show_sql
Output all SQL statements to the console. One additional option is to set the Org.hibernate.SQL log category to debug. eg. true | false
Hibernate.format_sql
Print more beautiful SQL in log and console. Value true | false
Hibernate.default_schema
In the generated SQL, attach the given schema/tablespace to the table name of the non-fully qualified name. Value schema_name
Hibernate.default_catalog
In the generated SQL, attach the given catalog to the name of the table that is not fully qualified. Value catalog_name
Hibernate.session_factory_name
When sessionfactory is created, it is automatically bound to Jndi using this name. Value jndi/composite/name
Hibernate.max_fetch_depth
Sets the maximum depth for a one-way association (single-to-one, many-to-a) outer join FETCH (OUTER join fetch) tree. A value of 0 means that the default outer join fetch will be turned off. Values are recommended from 0 to 3
Hibernate.default_batch_fetch_size
Set the default number for the batch crawl associated with hibernate. Values recommended are 4, 8, and
Hibernate.default_entity_mode
Specifies the default entity representation mode for all sessions opened by this sessionfactory . Value dynamic-map, dom4j, Pojo
Hibernate.order_updates
Forces hibernate to sort SQL updates according to the primary key of the data being updated. Doing so will reduce the deadlock of transactions in high concurrency systems. Value true | false
Hibernate.generate_statistics
If turned on, hibernate collects statistics that will help with performance tuning. Value true | false
Hibernate.use_identifer_rollback
If turned on, the identity property generated when the object is deleted is reset to the default value. Value true | false
Hibernate.use_sql_comments
If on, Hibernate generates comment information in SQL that is useful for debugging, and the default value is false. Value true | false
Table 3.4. Hibernate jdbc and connection (connection) Properties
Property name
Use
Hibernate.jdbc.fetch_size
A value other than 0 that specifies the size of the number of JDBC fetches (called statement.setfetchsize ()).
Hibernate.jdbc.batch_size
A non-0 value that allows hibernate to use JDBC2 Bulk update. Value is recommended to take a value between 5 and
Hibernate.jdbc.batch_versioned_data
If you want your JDBC driver to return the correct row count from executebatch () , set this property to true(it is usually safe to turn on this option). At the same time, Hibernate will use bulk DML for automatically versioned data. The default value is false. eg. true | false
Hibernate.jdbc.factory_class
Select a custom batcher. Most applications do not require this configuration property. eg. Classname.of.Batcher
Hibernate.jdbc.use_scrollable_resultset
Allows hibernate to use JDBC2 's scrollable result set. This option is necessary only if you are using a user-supplied JDBC connection, or hibernate uses the connected metadata. Value true | false
Hibernate.jdbc.use_streams_for_binary
Use Stream (System-level attribute) when JDBC reads binary (binary) or serializable (serializable) types. Value true | false
Hibernate.jdbc.use_get_generated_keys
After the data is inserted into the database, it is allowed to use JDBC3 Preparedstatement.getgeneratedkeys () to obtain the database-generated key (key). jdbc3+ drivers and jre1.4+ are required, set this value to False if your database driver encounters a problem with Hibernate's identity generator. By default, connected metadata is used to determine the ability to drive. Value true|false
Hibernate.connection.provider_class
The class name of the custom ConnectionProvider , which is used to provide a JDBC connection to hibernate. Value Classname.of.ConnectionProvider
Hibernate.connection.isolation
Sets the JDBC transaction isolation level. Review the java.sql.Connection to see the specifics of each value, but be aware that most databases do not support all isolation levels. Value 1, 2, 4, 8
Hibernate.connection.autocommit
Allow the cached JDBC connection to turn on auto-commit (AUTOCOMMIT) (not recommended). Value true | false
Hibernate.connection.release_mode
Specifies when hibernate releases the JDBC connection. By default, the JDBC connection is not released until the session is explicitly closed or disconnected. For the JTA data source of the application server, you should use after_statementso that the connection is released voluntarily after each JDBC call. For non-JTA connections, it is reasonable to use after_transaction to release the connection at the end of each transaction. Auto will select after_statementfor the JTA and CMT transaction policies and select after_transactionfor the JDBC transaction policy. Value on_close | after_transaction | after_statement | Auto
Hibernate.connection. <propertyName>
Pass the JDBC attribute PropertyName to drivermanager.getconnection () .
Hibernate.jndi. <propertyName>
Pass the property PropertyName to the Jndi initialcontextfactory .
Table 3.5. Hibernate Cache Properties
Property name
Use
Hibernate.cache.provider_class
The class name of the custom Cacheprovider . Value Classname.of.CacheProvider
Hibernate.cache.use_minimal_puts
Optimize the level two cache to minimize write operations at the expense of frequent read operations. In Hibernate3, this setting is useful for cluster caching, which is enabled by default for the implementation of the cluster cache. Value true|false
Hibernate.cache.use_query_cache
Allow query caching, individual queries still need to be set to cacheable. Value true|false
Hibernate.cache.use_second_level_cache
Can be used to completely prohibit the use of level two cache. For classes that specify <cache> in the mapping definition of a class, the level two cache is turned on by default. Value true|false
Hibernate.cache.query_cache_factory
Custom implements the class name of the Querycache interface, which defaults to the built-in Standardquerycache. Value Classname.of.QueryCache
Hibernate.cache.region_prefix
Prefix for the two-level cache domain name. Value prefix
Hibernate.cache.use_structured_entries
Forces hibernate to store data in a two-level cache in a more user-friendly format. Value true|false
Table 3.6. Hibernate Transaction Properties
Property name
Use
Hibernate.transaction.factory_class
A transactionfactory class name for the hibernate Transaction API (default is jdbctransactionfactory). Value classname.of.TransactionFactory
Jta. UserTransaction
A jndi name used by Jtatransactionfactory to get JTA usertransactionfrom the application server. Value jndi/composite/name
Hibernate.transaction.manager_lookup_class
A transactionmanagerlookup class name-This class is required when using a JVM-level cache, or using the Hilo generator in a JTA environment. Value classname.of.TransactionManagerLookup
Hibernate.transaction.flush_before_completion
If enabled, the session will be automatically cleaned (flush) after the transaction is completed. A better approach now is to use automatic session context management. Value true | false
Hibernate.transaction.auto_close_session
If turned on, the session will be automatically closed after the transaction is completed. A better approach now is to use automatic session context management. Value true | false
table 3.7. Other Properties
Property name
Use
Hibernate.current_session_context_class
Specify a (custom) policy for the current Session . eg. JTA | Thread | Custom. Class
Hibernate.query.factory_class
Select the implementation of the HQL parser. Take value org.hibernate.hql.ast.ASTQueryTranslatorFactory or Org.hibernate.hql.classic.ClassicQueryTranslatorFactory
Hibernate.query.substitutions
Maps a symbol in a hibernate query to a symbol in a SQL query (the symbol may be a function name or a constant name). Value hqlliteral=sql_literal, Hqlfunction=sqlfunc
Hibernate.hbm2ddl.auto
When sessionfactory is created, the database structure is checked automatically, or the DDL of the database schema is exported to the database. When you use create-drop , the database schema is dropped when you explicitly close sessionfactory . Value Validate | Update | Create | Create-drop
Hibernate.cglib.use_reflection_optimizer
Turn on Cglib to replace the run-time reflection mechanism (System-level properties). The reflection mechanism is sometimes useful in removing a mistake. Note that hibernate still needs to be cglib even if this optimization is turned off. You cannot set this property in hibernate.cfg.xml . Value true | false 3.4.1. SQL dialect
You should always set the Hibernate.dialect property to the correct org.hibernate.dialect.Dialect subclass for your database. If you specify a dialect, hibernate will use reasonable default values for some of the attributes listed above, saving you the effort to specify them manually.
Table 3.8. Hibernate SQL dialect (hibernate.dialect)
Rdbms
Dialect
DB2
Org.hibernate.dialect.DB2Dialect
DB2 as/400
Org.hibernate.dialect.DB2400Dialect
DB2 OS390
Org.hibernate.dialect.DB2390Dialect
PostgreSQL
Org.hibernate.dialect.PostgreSQLDialect
Mysql
Org.hibernate.dialect.MySQLDialect
MySQL with InnoDB
Org.hibernate.dialect.MySQLInnoDBDialect
MySQL with MyISAM
Org.hibernate.dialect.MySQLMyISAMDialect
Oracle (any version)
Org.hibernate.dialect.OracleDialect
Oracle 9i/10g
Org.hibernate.dialect.Oracle9Dialect
Sybase
Org.hibernate.dialect.SybaseDialect
Sybase Anywhere
Org.hibernate.dialect.SybaseAnywhereDialect
Microsoft SQL Server
Org.hibernate.dialect.SQLServerDialect
SAP DB
Org.hibernate.dialect.SAPDBDialect
Informix
Org.hibernate.dialect.InformixDialect
Hypersonicsql
Org.hibernate.dialect.HSQLDialect
Ingres
Org.hibernate.dialect.IngresDialect
Progress
Org.hibernate.dialect.ProgressDialect
Mckoi SQL
Org.hibernate.dialect.MckoiDialect
Interbase
Org.hibernate.dialect.InterbaseDialect
Pointbase
Org.hibernate.dialect.PointbaseDialect
Frontbase
Org.hibernate.dialect.FrontbaseDialect
Firebird
Org.hibernate.dialect.FirebirdDialect
table 3.9. Hibernate log Category
Category
Function
Org.hibernate.SQL
Log records for all SQL DML statements when they are executed
Org.hibernate.type
Log logging for all JDBC parameters
Org.hibernate.tool.hbm2ddl
Log records for all SQL DDL statements when they are executed
Org.hibernate.pretty
Logging of the status of all entities associated with it (up to 20) when session cleansing (flush)
Org.hibernate.cache
Logging of activity for all level two caches
Org.hibernate.transaction
Logging for transaction-related activities
Org.hibernate.jdbc
Get logging for all JDBC resources
Org.hibernate.hql.AST
Log hql and SQL AST analysis logs when parsing queries
Org.hibernate.secure
Log for JAAS authentication requests
Org.hibernate
Log any hibernate related information (more informative, but very helpful for error checking)
Table 3.10. JTA transactionmanagers
Transaction Factory class
Application Server
Org.hibernate.transaction.JBossTransactionManagerLookup
Jboss
Org.hibernate.transaction.WeblogicTransactionManagerLookup
Weblogic
Org.hibernate.transaction.WebSphereTransactionManagerLookup
Websphere
Org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
WebSphere 6
Org.hibernate.transaction.OrionTransactionManagerLookup
Orion
Org.hibernate.transaction.ResinTransactionManagerLookup
Resin
Org.hibernate.transaction.JOTMTransactionManagerLookup
Jotm
Org.hibernate.transaction.JOnASTransactionManagerLookup
JOnAS
Org.hibernate.transaction.JRun4TransactionManagerLookup
JRun4
Org.hibernate.transaction.BESTransactionManagerLookup
Borland ES
Hibernate parameter Setting list