Hibernate JDBC and Connection Properties
By: Felix in Hibernate Tutorials on 2010-12-29
The table below lists the Hibernate JDBC and Connection Properties and their purpose. For easier understanding, and example is also provided for each property.Property name | Purpose |
---|---|
hibernate.jdbc.fetch_size | A non-zero value determines the JDBC fetch size (callsStatement.setFetchSize()). |
hibernate.jdbc.batch_size | A
non-zero value enables use of JDBC2 batch updates by Hibernate.
e.g. recommended values between 5 and 30 |
hibernate.jdbc.batch_versioned_data | Set
this property to true if
your JDBC driver returns correct row counts from executeBatch().
It is usually safe to turn this option on. Hibernate will then use
batched DML for automatically versioned data. Defaults to false.
e.g. true | false |
hibernate.jdbc.factory_class | Select
a custom org.hibernate.jdbc.Batcher.
Most applications will not need this configuration property.
e.g. classname.of.BatcherFactory |
hibernate.jdbc.use_scrollable_resultset | Enables
use of JDBC2 scrollable resultsets by Hibernate. This property is
only necessary when using user-supplied JDBC connections. Hibernate
uses connection metadata otherwise.
e.g. true | false |
hibernate.jdbc.use_streams_for_binary | Use
streams when writing/reading binary or serializabletypes
to/from JDBC. *system-level
property*
e.g. true | false |
hibernate.jdbc.use_get_generated_keys | Enables
use of JDBC3 PreparedStatement.getGeneratedKeys()to
retrieve natively generated keys after insert. Requires JDBC3+
driver and JRE1.4+, set to false if your driver has problems with
the Hibernate identifier generators. By default, it tries to
determine the driver capabilities using connection metadata.
e.g. true|false |
hibernate.connection.provider_class | The
classname of a customorg.hibernate.connection.ConnectionProvider which
provides JDBC connections to Hibernate.
e.g. classname.of.ConnectionProvider |
hibernate.connection.isolation | Sets
the JDBC transaction isolation level. Checkjava.sql.Connection for
meaningful values, but note that most databases do not support all
isolation levels and some define additional, non-standard
isolations.
e.g. 1, 2, 4, 8 |
hibernate.connection.autocommit | Enables
autocommit for JDBC pooled connections (it is not recommended).
e.g. true | false |
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. For an application server JTA datasource, use after_statement to
aggressively release connections after every JDBC call. For a non-JTA
connection, it often makes sense to release the connection at the
end of each transaction, by using after_transaction. auto will
choose after_statement for
the JTA and CMT transaction strategies and after_transaction for
the JDBC transaction strategy.
e.g. auto (default) | on_close | after_transaction |after_statement This setting only affects Sessions returned fromSessionFactory.openSession. For Sessions obtained throughSessionFactory.getCurrentSession, the CurrentSessionContextimplementation configured for use controls the connection release mode for those Sessions. |
hibernate.connection.<propertyName> | Pass the JDBC property <propertyName> toDriverManager.getConnection(). |
hibernate.jndi.<propertyName> | Pass the property <propertyName> to the JNDIInitialContextFactory. |
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
- Data Science
- Android
- React Native
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Step by Step Hibernate - Your First Hibernate Application
A sample Hibernate Web Application using Servlets
Programmatic configuration in Hibernate
Tutorial Using the Java Persistence API (JPA) in Hibernate
Primary keys assigned by triggers in Hibernate
Assigned identifiers in Hibernate
Identity columns and sequences in Hibernate
EntityNameResolvers in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
equals() and hashCode() in Hibernate
Fetching strategies in Hibernate
Comments