"Hibernate" Hibernate.cfg.xml configuration file detailed

Source: Internet
Author: User

Hibernate profiles are primarily used to configure the various properties required by the database connection and hibernate runtime, which should be located in the Class folder classes of the application or Web program. Hibernate profiles support two forms, one in XML format and the other in Java properties file format, in the form of key = value. It is recommended to use a configuration file in XML format. The XML configuration file can be configured directly on the map file and automatically loaded by Hibernate, and the properties file must be encoded in the program to load the mapping file.


Note:Hibernatethe formerprefixcan be omitted, i.e.:Hibernate.dialectequivalent todialect

Configuration Properties for Hibernate:

Property name
attribute meaning and function
Hibernate.dialect
Configure Hibernate database dialect, hibernate can be optimized for special databases
Hibernate.show_sql Whether the output hibernate runs the SQL statement, true for output, false for not output. It is generally set to true in development testing and is set to False when the project is successfully deployed, speeding up the operation of the program.
Hibernate.format_sql Optimize the console output of the SQL statement, true to Yes, false to No.
Hibernate.default_schema
The default database.
Hibernate.session_factory_name When Sessionfactory is created, the name is automatically bound in Jndi
Hibernate.max_fetch_depth
For one-to-one, one-to-many external connections set the maximum fetch depth, the recommended value is 0-3, and if 0 it closes the outer join crawl
Hibernate.default_batch_fetch_size
Set the default number of batch fetches associated with hibernate, with values of 4, 8, or 16 recommended
Hibenate.default_entity_mode

Specifies the default entity representation mode for all sessions opened by Sessionfactory. Value Dynamic-map,dom4j,pojo

Hibernate.order_updates
Forces hibernate to sort SQL updates according to the primary key of the database being updated. Doing so will reduce the deadlock of transactions in high concurrency systems. A value of TRUE or False
Hibernate.generate_statistics
Hibernate collects statistical data that can help with performance tuning. A value of TRUE or False
Hibernate.use_identifer_rollback

If on, the identity property that is generated when the object is deleted is reset to the default value.

Hibernate.use_sql_comments
If on, Hibernate generates annotation information in SQL that will help you debug. True or False


Hibernate jdbc and connection (Connection) Properties

Note:RedColorMarkNote Properties,to beOpenHair-Time warpcommon to is attribute

Property name
attribute meaning and function
Hibernate.jdbc.fetch_size
Non-0 value, specifying the size of the number of JDBC fetches (call Statement.setfetchsize ())
Hibernate.jdbc.batch_size Non-0 value, allow Hibernate to use JDBC2 batch update, value recommendation 5-30 between
Hibernate.jdbc_batch_versioned_data Set to True, when ExecuteBatch () is called, JDBC can return the correct number of rows. Hibernate will use bulk DML for automatically versioned data. Default is False
Hibernate.jdbc.fatory_class Set up a self-customizing batcher. Most programs do not have to set this property
Hibernate.jdbc.use_scrollable_resultset Allows hibernate to use JDBC2 's scrollable result set, which is necessary only if the user-supplied JDBC connection is used, or hibernate uses the connected metadata. Ture or False
Hibernate.jdbc.use_streams_for_binary This is a system-level attribute. Use stream when reading or writing binary or serializable data types from JDBC. Optional value: True,false
Hibernate.jdbc.use_get_generated_keys Set to True to use JDBC3 's Preparedstatement.getgeneratedkeys () to retrieve the key values that are generated after insertion when the data is inserted into the table. Requires more than JDBC3 drivers and JRE1.4 versions above. Set this to False if Hibernate has problems generating identifiers. By default, the metadata of the connection is used to determine whether the database driver has this capability
Hibernate.connection.provider_class User-defined ConnectionProvider class for Hibernate, which is used to provide a JDBC connection to hibernate
Hibernate.connection.isolation

Set the JDBC transaction isolation level to see Java.sql.Connection to understand the specific meaning of each value, but most databases do not support all isolation levels. PS: The setting of this option is especially important in the case of a large number of concurrent user accesses. Values 1, 2, 4, 8

hibernate.connection.autocommit allow the cached JDBC connection to turn on autocommit (Qutocommit), which is not recommended. Value: True, False
hibernate.conn Ection.release_mode
Specifies when hibernate releases the JDBC connection, by default JDBC remains connected until the session reality is closed or disconnected. For the application server JTA data source, you should call after_statement so that the connection is actively released after each JDBC call, and for non-JTA connections, use After_transaction to release the connection at the end of the transaction. If set to Auto, After_statement is selected for the JTA and CMT transaction policies, and After_transaction is selected for the JDBC transaction policy. Value Auto (default) |no_close|after_statement|after_transaction. Note that these settings only work for the session that was obtained through sessionfactory.opensession. For the session obtained through Sessionfactory.getcurrentsession, the configured Currentsessioncontext implements the connection release mode for these sessions.
Hibernate.connection.<propertyname> Passing the JDBC attribute PropertyName to Drivermanager.getconnection ()
Hibernate.jndi.<propertyname> Descending attribute PropertyName passed to Jbdi Initialcontextfactory.


Hibernate Cache Properties

Property name
attribute meaning and function
Hibernate.cache.provider_class
Custom Cacheprovider class name, value Classname.of.CacheProvider
Hibernate.cache.use_minimal_puts The two-level cache is optimized to minimize writes at the expense of frequent reads, and in Hibernate3, this setting is useful for cluster caching, which is turned on by default for cluster caching. 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, the class is defined in the mapping definition of <cache> classes, will default to turn on level two cache. Value: True|fasle
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 Two cache domain name prefix, 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


Hibernate Transaction Properties:

Property name
attribute meaning and function
Hibernate.transaction.factory_class
A Transactionfactory class name for the Hibernate Transaction API (default jdbctranscactionfactory). Value Classname.of.TransactionFactory
Hibernate.transaction.manager_lookup_class

A Transactionmanagerlookup class name that 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. Now a better approach is to use automatic session context management. Value True|false
Hibernate.transaction.auto_close_session If enabled, the session will be automatically closed after the transaction is completed. Now a better approach is to use automatic session context management. Value True|false


Other properties:

Property name
attribute meaning and function
Hibernate.current_session_context_class
Specifies a policy for the current session. such as: Thread|managed|jta|custom. Class
Hibernate.query.factory_class Select the implementation of the HQL parser. Value Org.hibernate.hql.ast.ASTQueryTranslatorFactory 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 sometimes

More useful. 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


"Hibernate" Hibernate.cfg.xml configuration file detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.