3.5.4.7. Delimited Identifiers Support
OpenJPA provides support for delimited identifiers as defined in the JPA 2.0 specification.
Identifiers can either be automatically delimited or individually manually delimited.
To have OpenJPA automatically delimit identifiers, add the <delimited-identifiers/> tag to the mapping file as documented in the JPA specification.
You can manually delimit individual identifiers either in the annotations or in the definitions in the mapping file.
To delimit an identifier element in an annotation, surround it with double quotes.
In a mapping file, add " to both the beginning and end of the element.
When delimited identifiers has been specified, OpenJPA will delimit SQL identifiers in the generated SQL statements.
It will use database-specific delimiters as defined in the appropriate database dictionary.
By default, the leading and trailing delimiters are both double quotes, (").
Different defaults for other dictionaries provided by OpenJPA are in the following table.
| Dictionary | Leading Delimiter | Trailing Delimiter |
|---|---|---|
MySQLDictionary |
` |
` |
AccessDictionary |
[ |
] |
HerdDBDictionary |
` |
` |
Some databases support more than one set of delimiters, often based on configuration.
If you need values different than the default values, you can set the LeadingDelimiter and the TrailingDelimiter dictionary properties.
You can specify whether or not the particular database that you are using supports delimited identifiers by setting the SupportsDelimitedIdentifiers dictionary property.
If this value is set to false, identifiers will not be automatically delimited, even if the <delimited-identifiers/> tag is specified in the mapping file.
Limitation: The columnDefinition elements in identifiers are not automatically delimited by OpenJPA when using the <delimited-identifiers/> tag in the mapping file.
If you want these to be delimited, you must manually delimit them in the annotation or mapping file definitions.