In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the Hibernate configuration items". In the daily operation, I believe many people have doubts about the Hibernate configuration items. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the Hibernate configuration items?" Next, please follow the editor to study!
1.Hibernate configuration item
(1) after the dialect is specified by hibernate.dialect, Hibernate can automatically generate optimized SQL according to the low-level database. The inherited class whose value is org.hibenate.dialect.Dialect. In most cases, the Hibernate can be judged by the metadata returned by the lower-level JDBC.
(2) hibernate.show_sql prints all SQL statements to the console, and you can achieve the same effect by setting the log policy of the org.hibernate.SQL class to the DEBUG level. Value: true | false.
(3) hibernate.format_sql formatted SQL statements when printing to the console or writing to a log file. Value: true | false.
(4) when hibernate.default_schema generates the SQL statement, add the table space (tablespace) or database schema (schema) given by the mapping file before the table name. Value: SCHEMA_NAME.
(5) when hibernate.default_catalog generates a SQL statement, add the catalog given by the mapping file before the table name. Value: CATALOG_NAME.
(6) after hibernate.session_factory_name Hibernate creates an org.hibernate.SessionFactory instance, it will automatically bind this to the name in JNDI. Value: jndi/sf.
(7) hibernate.max_fetch_depth sets the number of outer joins to a single table * depth. 0 is the mask default external connection setting. The recommended setting is between 0 and 3.
(8) hibernate.default_batch_fetch_size sets the scale of Hibernate batch federation query. It is strongly recommended. The recommended setting is 4, 8, 16.
(9) the default entity representation mode of hibernate.default_entity_mode, all Session opened through SessionFactory. Value: dynamic-map, dom4j, pojo.
(10) hibernate.order_updates forces Hibernate to order SQL updates by the primary key values of the updated items. This reduces transaction deadlocks at high concurrency. Value: true | false.
(11) if hibernate.generate_statistics is set to true,Hibernate, statistics will be collected for performance adjustment. Value: true | false.
(12) if hibernate.use_identifier_rollback is set to true, the resulting identity property will be reset to the default value when the object is deleted. The value is true | false.
(13) if hibernate.use_sql_comments is set to true,Hiberante, comments will be generated for SQL, which is more convenient for debugging. The default is false. The value is true | false.
Properties of 2.Hibernate JDBC and connection
(1) hibernate.jdbc.fetch_size specifies the query scale of JDBC. By calling (Statement.setFetchSize ()).
(2) hibernate.jdbc.batch_size specifies how Hibernate uses JDBC2 for batch updates. Value: 5 to 30 is recommended.
(3) setting this property to true,JDBC by hibernate.jdbc.batch_versioned_data will return the correct number of rows after executeBatch execution. It is usually safe to turn on this parameter. Hibernate will automatically decode this data using bulk DML. The default is false. Value: true | false.
(4) hibernate.jdbc.factory_class chooses a custom org.hibernate.jdbc.Batcher. All applications do not need to configure this property. Value to define the class name of the factory.
(5) hibernate.jdbc.use_scrollable_resultset Hibernate uses JDBC2's scrollable recordset. This parameter needs to be set when using a user-provided JDBC connection. Otherwise, Hibernate uses the connection MetaData. Value: true | false.
Hibernate.jdbc.use_streams_for_binary uses streams when reading or writing binary data or serializing data from JDBC or to JDBC. System-level data. Set true | false.
(7) after hibernate.jdbc.use_get_generated_keys is inserted, you can use the value in PreparedStatement.getGeneratedKeys () of JDBC3 to retrieve the locally generated key value. Require JDBC3+ and JRE1.4+, if there is something wrong with your driver after using Hibernate identifier generator, please set it to false. By default, try to connect to the MetaData to decide. Value: true | false.
(8) hibernate.connection.provider_class implements the name of the class of the org.hibernate.connection.ConnectionProvider interface, providing a connection for Hibernate.
(9) hibernate.connection.isolation sets the level of JDBC transaction isolation. Check the constant values defined by java.sql.Connection, but note that most databases do not support all isolation levels, some additional and non-standard isolation levels. Values: 1, 2, 4, 8.
(10) automatic submission of hibernate.connection.autocommit JDBC shared connections. (not recommended) value: true | false.
(11) hibernate.connection.release_mode specifies when Hibernate should release JDBC connections. By default, JDBC is always there until the Session is explicitly closed or disconnected. For the application's server JTA data source, you should use after_statement to force the release of JDBC connections at the end of each JDBC request. For non-JTA data sources, it usually makes sense to release the JDBC connection at the end of each transaction. When this value is set to auto, after_statement mode is selected for JTA and CMT transaction strategies. When JDBC transaction strategy, select after_transaction. Value: auto (default), on_close,after_statment,after_transaction.
Note: this setting only affects session opened through SessionFactory.openSession. The configuration of the session,CurrentSessionContext implementation classes obtained through SessionFactory.getCurrentSession is used to control the connection release mode of these session.
(12) hibernate.connection. Pass these attributes to the DriverManager.getConnection.
(13) hibernate.jndi. Pass these attributes to JNDI InitialContextFactory.
3.Hibernate Cache attribute
(1) the class name of the CacheProvider customized by hibernate.cache.provider_class.
(2) hibernate.cache.use_minimal_puts spends more read operations to optimize the minimum write operations of the secondary cache. This operation is very useful for cluster caching. In Hibernate3, this feature is enabled by default for cluster caching. Value: true | false.
(3) hibernate.cache.use_query_cache enables query caching, and individual queries should definitely enable query caching. Value: true | false.
(4) hibernate.cache.use_second_level_cache may be used to completely blocking the secondary cache, which is turned on by default, in the case of a specified CacheProvider implementation class. Value: true | false.
(5) hibernate.cache.query_cache_factory implements the class name of the QueryCache interface. The default is built-in StandardQueryCache.
(6) the prefix of hibernate.cache.region_prefix for using secondary cache domain names.
(7) hibernate.cache.use_structured_entries forces Hibernate to use a more user-friendly format when storing data in a secondary cache. Value: true | false.
4.Hibernate transaction properties
(1) hibernate.transaction.transaction_class uses the class name of TransactionFactory of the Hibernate transaction APIs. The default is JDBCTransactionFactory.
(2) jta.UserTransaction JTATransactionFactory uses the JNDI name to get the JTA UserTransaction from the application server. Value: jndi/ut.
(3) hibernate.transaction.manager_lookup_class is the class name of a TransactionManagerLookup implementation class. This value is required when JVM-level caching is turned on or when hilo generator is used in a JTA environment.
(4) if hibernate.transaction.flush_before_completion is set to true,session, the value of the cache will be automatically pushed into the database before the transaction completion phase. Built-in and automatic session context management are preferred. Value: true | false.
(5) if hibernate.transaction.auto_close_session is set to true,session, session will be automatically closed after the transaction is completed. Built-in and automatic session context management are preferred. Value: true | false.
Various mixed properties of 5.Miscellaneous properties
(1) hibernate.current_session_context_class provides a strategy for the current session lifecycle. Value: jta, thread, managed, custom class name.
(2) hibernate.query.factory_class chooses the parsing implementation class of HSQL. Values: org.hibernate.hsql.ast.ASTQueryTranslatorFactory and org.hibernate.hsql.classic.ClassicQueryTranslatorFactory.
(3) Mapping of markers in hibernate.query.subsitutions Hibernate to markers in SQL. For example, it can be a function name or a normal string name. Value, such as hsqLiteral=SQL_LITERAL,hqlFunction=SQLFUN.
(4) hibernate.hbm2ddl.auto automatically validates or outputs schema DDL (that is, table statements) to the database when the SessionFactory is created. In other words, the database table structure is automatically verified or deleted and then re-established, or the data table structure is updated on the original table structure. When the value is set to create-drop, the table structure in the database is deleted when SessionFactory is cleared. Value: validate, create, update, create-drop.
(5) hibernate.cglib.use_reflection_optimizer replaces the runtime reflection (system-level attribute) with CGLIB. Reflection is very useful when there is a failure. Note that Hibernate always requires CGLIB, even after you turn off the optimization. You cannot set this property in the hibernate.cfg.xml file.
At this point, the study of "what are the Hibernate configuration items" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.