Hibernate JDBC and Connection Properties
By: Felix
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. |
Archived Comments
- Data Science
- Android
- 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
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
Creating Connection Pool for JDBC Connections in Hibernate
Hibernate JDBC and Connection Properties
Hibernate Transaction Properties