Spring Sessionfactory Property configuration in detail, various properties in ApplicationContext

Source: Internet
Author: User
Tags informix interbase postgresql org sybase

The ID of the 1.Bean is sessionfactory, and the corresponding class is annotationsessionfactory, i.e., Hibernate is implemented in the form of annotations.

2.hibernateProperties, configuring Hibernate properties

1) hibernate.dialect, configuring Hibernate dialect, allows hibernate to use specific database platform features, specific dialect Daquan:

The values for this property in different databases are as follows. Where attributes are worth formatting: {hibernatejar full name}.dialaect. {corresponding Database} Dialect

Hibernatesql 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

Oracle (any version)

Org.hibernate.dialect.OracleDialect

Oracle 9

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

2) hibernate.query.substitutions, query language substitution, some phrases in hibernate query are replaced with SQL phrases. The value True=1,false=0,tolowercase=lower represents replacing true with 1,false replacing 0,tolowercase with lower when generating SQL statements

3) Hibernate.show_sql=true, the execution of the SQL statements are output to the console, so that the programmer to observe the execution of SQL.

4) Hibernate.hbm2ddl.auto=none, indicates that no operations are automatically performed on the database based on hibernate configuration. The other property values are as follows:

Create: Indicates that the sessionfactory starts by dropping the table, then create, the database table data will be lost.
Create-drop: Also means create, except to perform a drop before Sessionfactory is closed.
Update:sessionfactory will check to see if the schema is consistent when it starts, and it is the most common attribute if the inconsistency will be a scheme update. The table is generated based on Hibernate persistence class, even if the table structure changes, the rows in the table still exist and the previous rows Hibernate persisted class generation table is not deleted, even if the table structure changes, the rows in the table still exist and the previous rows are not deleted
Validate: Verify that the existing database table schema is consistent with the hibernate you configured when you start, and throws an exception if there is an inconsistency and does not update

In addition, Hibernate configuration Properties Daquan:

Hibernate.dialect:A Hibernatedialect class name allows hibernate to generate optimized SQL for a particular relational database. Value Full.classname.of.Dialect (see below) Hibernate.show_sql:To output all SQL statements to the console, there is an additional option to set the Org.hibernate.SQL logcategory 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, append the given scheam/tablespace to the table name of the non-fully qualified name, taking the value schema_name Hibernate.default_catelog:In the generated SQL, attach the given catalog to the name of the table that is not fully qualified. Take value catalog_name. Hibernate.session_factory_name:When Sessionfactory is created, it is automatically bound to Jndi using this name, and the value is 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 (outerjoin fetch) tree. A value of 0 means that the default outer join fetch is turned off. Values are recommended from 0 to 3. hibernate.default_batch_fetch_size: Sets the default number for the batch crawl associated with hibernate. Recommended values are 4, 8, and 16. Hibernate.default_entity_mode:Specify the default entity representation mode for all sessions opened by this sessionfactory, and 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 annotation information in SQL that helps to tune. The default is false to value True|false ========================================================================================== ========- Hibernate JDBC and Connection (Connection) Properties hibernate.jdbc.fetch_size:Non-0 value, specifying the size of the number of JDBC fetches (call Statement.setfetchsize ()) hibernate.jdbc.batch_size:A non-0 value that allows hibernate to use JDBC2 's bulk update, with values suggested from 5 to 30. Hibernate.jdbc.tatch_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) and hibernate will use bulk DML for automatically versioned data. The default is False. Eg:true|false Hibernate.jdbc.factory_class:Select a custom batcher. Most applicationsThe program does not need to configure this property. Eg:classname.of.Batcher Hibernate.jdbc.use_scrollable_resultset:Allows hibernate to use JDBC2 's scrollable result set, which is necessary when using a user-supplied JDBC connection, or hibernate uses the concatenated metadata to value True|false hibernate.jdbc.use_streams_for_binary:When JDBC reads binary (binary) or serializable (serializable) types, the stream (stream) (System-level attribute) is used to take the value True|falsehibernate.jdbc.use_get_generated_keys: After the data is inserted into the database, it is allowed to use Jdbc3preparedstatement.getgeneratedkeys () to obtain the database-generated key (key). Requires jdbc3+ driver and jre1.4+, if your database driver encounters a problem with Hibernate's identity generator, set the secondary value to false and use the connected metadata to determine the drive capability by default.  Value True|falsehibernate.connection.provider_class: The class name of the custom ConnectionProvider, which is used to provide a JDBC connection to Hibernate.  The 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 allows 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_statement so 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_statement for the JTA and CMT transaction policies and select After_transaction for the JDBC transaction policy. Value On_close | after_transaction | after_statement | Auto hibernate.connection:Pass the JDBC attribute propertyname to Drivermanager.getconnection (). Hibernate.jndi:Pass the attribute PropertyName to Jndiinitialcontextfactory ================================================================== ================================   Hibernate Cache Properties
Hibernate.cache.provider_class the class name of the custom Cacheprovider. Value Classname.of.CacheProvider
The hibernate.cache.use_minimal_puts optimizes 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 are specified in the mapping definition of a class, the level two cache is turned on by default. Value True|false
The 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 two-level cache domain names. 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
Hibernate.transaction.factory_class a Transactionfactory class name for the Hibernate transaction API (the default is Jdbctransactionfactory  ). Value Classname.of.TransactionFactory
Jta.  UserTransaction a jndi name used by Jtatransactionfactory to obtain JTA usertransaction from 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 enabled, 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 ================================================================================================== Hibernate other PropertiesHIBERNATE.CURRENT_SESSION_CONTEXT_CLASS specifies 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 automatically checks the database structure when sessionfactory is created, or exports the DDL of the database schema 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 turns 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 ====================================================================================== SQL dialectYou 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. 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 ================================================================= ================================= Hibernate log CategoryOrg.hibernate.SQL Logging for all SQL DML statements when they are executed
Org.hibernate.type logging for all JDBC parameters
ORG.HIBERNATE.TOOL.HBM2DDL logging for all SQL DDL statements when they are executed
Org.hibernate.pretty logging for all entities associated with it (up to 20) when the session is cleaned (flush)
Org.hibernate.cache activity logging for all level two caches
Org.hibernate.transaction Logging for transaction-related activities
ORG.HIBERNATE.JDBC get log for all JDBC resources
Org.hibernate.hql.AST log hql and SQL for AST analysis when parsing queries
Org.hibernate.secure Log for JAAS authentication requests
Org.hibernate Log for any hibernate related information (more informative, but very helpful for troubleshooting) ============================================================ ==========================

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

<property name= "Hibernateproperties" > <props> <prop key= "Hibernate.cache.use_second_level_cache" > True </prop> <prop key= "Hibernate.cache.provider_class" > Org.hibernate.cache.EhCacheProvide    R </prop> <prop key= "Hibernate.dialect" > Org.hibernate.dialect.SQLServerDialect </prop> <!--prop key= "Hibernate.cglib.use_reflection_optimizer" > True </prop--> <prop key= "Hibernate.que Ry.factory_class "> <!--org.hibernate.hql.classic.ClassicQueryTranslatorFactory-Org.hibernate.hql.ast . Astquerytranslatorfactory </prop> <prop key= "Hibernate.show_sql" >false</prop> <!--Hibernat E to maintain the persistence of the entity class <prop key= "Hibernate.hbm2ddl.auto" >create</prop> "<prop key=" Hibernate.hbm2ddl.auto ">update</prop> <prop key=" Hibernate.connection.useUnicode ">true</prop > <prop key= "hibernate.connection.characterEncoding"; GBK </prop> <!--using level two cache and query caching for improved performance--<prop key= "Hibernate.cache.use_query_cache" >true</prop > <prop key= "Hibernate.cache.provider_class" > Org.hibernate.cache.EhCacheProvider </prop> </ Props> </property>

Spring sessionfactory Property configuration in detail, applicationcontext various properties in detail

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.