3.5.4. Database Support
OpenJPA can take advantage of any JDBC 2.x compliant driver, making almost any major database a candidate for use. See our officially supported database list in Supported Databases for more information. Typically, OpenJPA auto-configures its JDBC behavior and SQL dialect for your database, based on the values of your connection-related configuration properties.
If OpenJPA cannot detect what type of database you are using, or if you are using an unsupported database, you will have to tell OpenJPA what
org.apache.openjpa.jdbc.sql.DBDictionary to use.
The DBDictionary abstracts away the differences between databases.
You can plug a dictionary into OpenJPA using the openjpa.jdbc.DBDictionary configuration property.
The built-in dictionaries are listed below.
If you are using an unsupported database, you may have to write your own DBDictionary subclass, a simple process.
-
access: Dictionary for Microsoft Access. This is an alias for the org.apache.openjpa.jdbc.sql.AccessDictionary class. -
db2: Dictionary for IBM’s DB2 database. This is an alias for the org.apache.openjpa.jdbc.sql.DB2Dictionary class. -
derby: Dictionary for the Apache Derby database. This is an alias for the org.apache.openjpa.jdbc.sql.DerbyDictionary class. -
empress: Dictionary for Empress database This is an alias for the org.apache.openjpa.jdbc.sql.EmpressDictionary class. -
foxpro: Dictionary for Microsoft Visual FoxPro. This is an alias for the org.apache.openjpa.jdbc.sql.FoxProDictionary class. -
h2: Dictionary for the H2 Database Engine. This is an alias for the org.apache.openjpa.jdbc.sql.H2Dictionary class. -
hsql: Dictionary for the Hypersonic SQL database. This is an alias for the org.apache.openjpa.jdbc.sql.HSQLDictionary class. -
informix: Dictionary for the Informix database. This is an alias for the org.apache.openjpa.jdbc.sql.InformixDictionary class. -
ingres: Dictionary for Ingres. This is an alias for the org.apache.openjpa.jdbc.sql.IngresDictionary class. -
jdatastore: Dictionary for Borland JDataStore. This is an alias for the org.apache.openjpa.jdbc.sql.JDataStoreDictionary class. -
mariadb: Dictionary for the MariaDB database. This is an alias for the org.apache.openjpa.jdbc.sql.MariaDBDictionary class. -
mysql: Dictionary for the MySQL database. This is an alias for the org.apache.openjpa.jdbc.sql.MySQLDictionary class. -
oracle: Dictionary for Oracle. This is an alias for the org.apache.openjpa.jdbc.sql.OracleDictionary class. -
pointbase: Dictionary for Pointbase Embedded database. This is an alias for the org.apache.openjpa.jdbc.sql.PointbaseDictionary class. -
postgres: Dictionary for PostgreSQL. This is an alias for the org.apache.openjpa.jdbc.sql.PostgresDictionary class. -
soliddb: Dictionary for IBM’s SolidDB database. This is an alias for the org.apache.openjpa.jdbc.sql.SolidDBDictionary class. -
sqlserver: Dictionary for Microsoft’s SQL Server database. This is an alias for the org.apache.openjpa.jdbc.sql.SQLServerDictionary class. -
sybase: Dictionary for Sybase. This is an alias for the org.apache.openjpa.jdbc.sql.SybaseDictionary class.
The example below demonstrates how to set a dictionary and configure its properties in your configuration file.
The DBDictionary property uses OpenJPA’s plugin syntax .
<property name="openjpa.jdbc.DBDictionary" value="hsql(SimulateLocking=true)"/>