We need to specify mapping information that defines how your Java classes relate to the database tables. Hibernate also requires a set of configuration settings related to database and other related parameters. All such information is usually configured as a Java properties file called hibernate.properties, or as an XML file called hibernate.cfg.xml.
I will use XML formatted file hibernate.cfg.xml to specify required Hibernate properties in this examples. Most of the properties take their default values and it is not required to specify them in the property file unless it is really required. hibernate.cfg.xml file is kept in application's classpath.
hibernate.dialect
This property makes Hibernate generate the appropriate SQL for the chosen database.
hibernate.connection.driver_class
The JDBC driver class.
hibernate.connection.url
The JDBC URL to the database instance.
hibernate.connection.username
The database username.
hibernate.connection.password
The database password.
hibernate.connection.pool_size
Limits the number of connections waiting in the Hibernate database connection pool.
hibernate.connection.autocommit
Allows auto commit mode to be used for the JDBC connection.
hibernate.connection.datasource
The JNDI name defined in the application server context you are using for the application.
hibernate.jndi.class
The InitialContext class for JNDI.
hibernate.jndi.<JNDIpropertyname>
Passes any JNDI property you like to the JNDI InitialContext.
hibernate.jndi.url
Provides the URL for JNDI.
hibernate.connection.username
The database username.
hibernate.connection.password
The database password.
I will use XML formatted file hibernate.cfg.xml to specify required Hibernate properties in this examples. Most of the properties take their default values and it is not required to specify them in the property file unless it is really required. hibernate.cfg.xml file is kept in application's classpath.
Hibernate Properties
List of properties used in hibernate configuration file (hibernate.cfg.xml /hibernate.properties) given below.
Properties used to configure database for Standalone situation is listed below
hibernate.dialect
This property makes Hibernate generate the appropriate SQL for the chosen database.
hibernate.connection.driver_class
The JDBC driver class.
hibernate.connection.url
The JDBC URL to the database instance.
hibernate.connection.username
The database username.
hibernate.connection.password
The database password.
hibernate.connection.pool_size
Limits the number of connections waiting in the Hibernate database connection pool.
hibernate.connection.autocommit
Allows auto commit mode to be used for the JDBC connection.
Properties used to configure database with application server and JNDI is listed below
hibernate.connection.datasource
The JNDI name defined in the application server context you are using for the application.
hibernate.jndi.class
The InitialContext class for JNDI.
hibernate.jndi.<JNDIpropertyname>
Passes any JNDI property you like to the JNDI InitialContext.
hibernate.jndi.url
Provides the URL for JNDI.
hibernate.connection.username
The database username.
hibernate.connection.password
The database password.
Hibernate Configuration File
hibernate.cfg.xml
org.hibernate.dialect.MySQLDialect com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/test username password 1 thread org.hibernate.cache.internal.NoCacheProvider true create
This configuration file used to configure MySQL database with hibernate . We can configure any database by changing values of hibernate.dialect, hibernate.connection.driver_class properties
Databases dialect property type
List of popular database dialect properties
CUBRID 8.3 and later
|
org.hibernate.dialect.CUBRIDDialect
|
DB2
|
org.hibernate.dialect.DB2Dialect
|
DB2 AS/400
|
org.hibernate.dialect.DB2400Dialect
|
DB2 OS390
|
org.hibernate.dialect.DB2390Dialect
|
Firebird
|
org.hibernate.dialect.FirebirdDialect
|
FrontBase
|
org.hibernate.dialect.FrontbaseDialect
|
H2
|
org.hibernate.dialect.H2Dialect
|
HyperSQL (HSQL)
|
org.hibernate.dialect.HSQLDialect
|
Informix
|
org.hibernate.dialect.InformixDialect
|
Ingres
|
org.hibernate.dialect.IngresDialect
|
Ingres 9
|
org.hibernate.dialect.Ingres9Dialect
|
Ingres 10
|
org.hibernate.dialect.Ingres10Dialect
|
Interbase
|
org.hibernate.dialect.InterbaseDialect
|
InterSystems Cache 2007.1
|
org.hibernate.dialect.Cache71Dialect
|
JDataStore
|
org.hibernate.dialect.JDataStoreDialect
|
Mckoi SQL
|
org.hibernate.dialect.MckoiDialect
|
Microsoft SQL Server 2000
|
org.hibernate.dialect.SQLServerDialect
|
Microsoft SQL Server 2005
|
org.hibernate.dialect.SQLServer2005Dialect
|
Microsoft SQL Server 2008
|
org.hibernate.dialect.SQLServer2008Dialect
|
Microsoft SQL Server 2012
|
org.hibernate.dialect.SQLServer2012Dialect
|
Mimer SQL
|
org.hibernate.dialect.MimerSQLDialect
|
MySQL
|
org.hibernate.dialect.MySQLDialect
|
MySQL with InnoDB
|
org.hibernate.dialect.MySQLInnoDBDialect
|
MySQL with MyISAM
|
org.hibernate.dialect.MySQLMyISAMDialect
|
MySQL5
|
org.hibernate.dialect.MySQL5Dialect
|
MySQL5 with InnoDB
|
org.hibernate.dialect.MySQL5InnoDBDialect
|
Oracle 8i
|
org.hibernate.dialect.Oracle8iDialect
|
Oracle 9i
|
org.hibernate.dialect.Oracle9iDialect
|
Oracle 10g and later
|
org.hibernate.dialect.Oracle10gDialect
|
Oracle TimesTen
|
org.hibernate.dialect.TimesTenDialect
|
Pointbase
|
org.hibernate.dialect.PointbaseDialect
|
PostgreSQL 8.1
|
org.hibernate.dialect.PostgreSQL81Dialect
|
PostgreSQL 8.2
|
org.hibernate.dialect.PostgreSQL82Dialect
|
PostgreSQL 9 and later
|
org.hibernate.dialect.PostgreSQL9Dialect
|
Progress
|
org.hibernate.dialect.ProgressDialect
|
SAP DB
|
org.hibernate.dialect.SAPDBDialect
|
SAP HANA (column store)
|
org.hibernate.dialect.HANAColumnStoreDialect
|
SAP HANA (row store)
|
org.hibernate.dialect.HANARowStoreDialect
|
Sybase
|
org.hibernate.dialect.SybaseDialect
|
Sybase 11
|
org.hibernate.dialect.Sybase11Dialect
|
Sybase ASE 15.5
|
org.hibernate.dialect.SybaseASE15Dialect
|
Sybase ASE 15.7
|
org.hibernate.dialect.SybaseASE157Dialect
|
Sybase Anywhere
|
org.hibernate.dialect.SybaseAnywhereDialect
|
Teradata
|
org.hibernate.dialect.TeradataDialect
|
Unisys OS 2200 RDMS
|
org.hibernate.dialect.RDMSOS2200Dialect
|
0 comments:
Post a Comment