mirror of https://github.com/apache/openjpa.git
OPENJPA-2162. Allow the setting of the DBDictionary property supportsDelimitedIdentifiers to "false" to skip the extra overhead of processing delimited identifiers when they will not exist for a given application or usage.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1307157 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
42372cf609
commit
0354b057c9
|
@ -392,7 +392,7 @@ public class DBDictionary
|
||||||
|
|
||||||
// NamingConfiguration properties
|
// NamingConfiguration properties
|
||||||
private boolean delimitIdentifiers = false;
|
private boolean delimitIdentifiers = false;
|
||||||
public boolean supportsDelimitedIdentifiers = true;
|
public Boolean supportsDelimitedIdentifiers = null;
|
||||||
public String leadingDelimiter = "\"";
|
public String leadingDelimiter = "\"";
|
||||||
public String trailingDelimiter = "\"";
|
public String trailingDelimiter = "\"";
|
||||||
public String nameConcatenator = "_";
|
public String nameConcatenator = "_";
|
||||||
|
@ -474,7 +474,8 @@ public class DBDictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the naming utility
|
// Configure the naming utility
|
||||||
configureNamingUtil(metaData);
|
if (supportsDelimitedIdentifiers == null) // not explicitly set
|
||||||
|
configureNamingUtil(metaData);
|
||||||
|
|
||||||
// Auto-detect generated keys retrieval support
|
// Auto-detect generated keys retrieval support
|
||||||
// unless user specified it.
|
// unless user specified it.
|
||||||
|
@ -5380,20 +5381,27 @@ public class DBDictionary
|
||||||
* @return the supportsDelimitedIds
|
* @return the supportsDelimitedIds
|
||||||
*/
|
*/
|
||||||
public boolean getSupportsDelimitedIdentifiers() {
|
public boolean getSupportsDelimitedIdentifiers() {
|
||||||
return supportsDelimitedIdentifiers;
|
return (supportsDelimitedIdentifiers == null ? false : supportsDelimitedIdentifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param supportsDelimitedIds the supportsDelimitedIds to set
|
* @param supportsDelimitedIds the supportsDelimitedIds to set
|
||||||
*/
|
*/
|
||||||
public void setSupportsDelimitedIdentifiers(DatabaseMetaData metaData) {
|
public void setSupportsDelimitedIdentifiers(boolean supportsDelimitedIds) {
|
||||||
|
supportsDelimitedIdentifiers = Boolean.valueOf(supportsDelimitedIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param metadata the DatabaseMetaData to use to determine whether delimiters can be supported
|
||||||
|
*/
|
||||||
|
private void setSupportsDelimitedIdentifiers(DatabaseMetaData metaData) {
|
||||||
try {
|
try {
|
||||||
supportsDelimitedIdentifiers =
|
supportsDelimitedIdentifiers = Boolean.valueOf(
|
||||||
metaData.supportsMixedCaseQuotedIdentifiers() ||
|
metaData.supportsMixedCaseQuotedIdentifiers() ||
|
||||||
metaData.storesLowerCaseQuotedIdentifiers() ||
|
metaData.storesLowerCaseQuotedIdentifiers() ||
|
||||||
metaData.storesUpperCaseQuotedIdentifiers();
|
metaData.storesUpperCaseQuotedIdentifiers());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
supportsDelimitedIdentifiers = false;
|
supportsDelimitedIdentifiers = Boolean.valueOf(false);
|
||||||
getLog().warn(_loc.get("unknown-delim-support", e));
|
getLog().warn(_loc.get("unknown-delim-support", e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5508,11 +5516,17 @@ public class DBDictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toDBName(DBIdentifier name) {
|
public String toDBName(DBIdentifier name) {
|
||||||
return getNamingUtil().toDBName(name);
|
if (!getSupportsDelimitedIdentifiers())
|
||||||
|
return name.getName();
|
||||||
|
else
|
||||||
|
return getNamingUtil().toDBName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toDBName(DBIdentifier name, boolean delimit) {
|
public String toDBName(DBIdentifier name, boolean delimit) {
|
||||||
return getNamingUtil().toDBName(name, delimit);
|
if (!getSupportsDelimitedIdentifiers())
|
||||||
|
return name.getName();
|
||||||
|
else
|
||||||
|
return getNamingUtil().toDBName(name, delimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DBIdentifier fromDBName(String name, DBIdentifierType id) {
|
public DBIdentifier fromDBName(String name, DBIdentifierType id) {
|
||||||
|
|
Loading…
Reference in New Issue