mirror of https://github.com/apache/openjpa.git
OPENJPA-1115 Eliminate alias conversion on configurations that do not require conversion.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@900985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
245bb82d34
commit
9e73688412
|
@ -419,6 +419,10 @@ public class DBIdentifierUtilImpl extends IdentifierUtilImpl implements DBIdenti
|
|||
* Converts a column alias to use the appropriate delimiters
|
||||
*/
|
||||
public String convertAlias(String alias) {
|
||||
if (!needsConversion(getIdentifierConfiguration())) {
|
||||
return alias;
|
||||
}
|
||||
|
||||
String[] names = Normalizer.splitName(alias);
|
||||
if (names.length <= 1) {
|
||||
// Nothing to split
|
||||
|
|
|
@ -29,6 +29,7 @@ public class DefaultIdentifierConfiguration implements IdentifierConfiguration {
|
|||
|
||||
private DBIdentifierRule normalizingRule = new DBIdentifierRule();
|
||||
private Map<String, IdentifierRule> normalizingRules = new HashMap<String, IdentifierRule>();
|
||||
private final String conversionKey = getLeadingDelimiter() + getIdentifierDelimiter() + getTrailingDelimiter();
|
||||
|
||||
public DefaultIdentifierConfiguration() {
|
||||
normalizingRules.put(IdentifierRule.DEFAULT_RULE, normalizingRule);
|
||||
|
@ -78,4 +79,8 @@ public class DefaultIdentifierConfiguration implements IdentifierConfiguration {
|
|||
public boolean getSupportsDelimitedIdentifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getConversionKey() {
|
||||
return conversionKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,6 +373,7 @@ public class DBDictionary
|
|||
public String delimitedCase = SCHEMA_CASE_PRESERVE;
|
||||
public String catalogSeparator = ".";
|
||||
private String defaultSchemaName = null;
|
||||
private String conversionKey = null;
|
||||
|
||||
// Naming utility and naming rules
|
||||
private DBIdentifierUtil namingUtil = null;
|
||||
|
@ -5361,4 +5362,12 @@ public class DBDictionary
|
|||
public String getDefaultSchemaName() {
|
||||
return defaultSchemaName;
|
||||
}
|
||||
|
||||
public String getConversionKey() {
|
||||
if (conversionKey == null) {
|
||||
conversionKey = getLeadingDelimiter() + getIdentifierDelimiter() +
|
||||
getTrailingDelimiter();
|
||||
}
|
||||
return conversionKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,4 +86,13 @@ public interface IdentifierConfiguration {
|
|||
* @return upper, lower, or preserve
|
||||
*/
|
||||
public String getSchemaCase();
|
||||
|
||||
/**
|
||||
* Returns a key that can be used to determine whether conversion
|
||||
* should take place. Id configurations should create a key unique
|
||||
* to their configuration. The typical key is:
|
||||
* leading delimiter (") + name separator(.) + trailing delimiter(")
|
||||
* @return
|
||||
*/
|
||||
public String getConversionKey();
|
||||
}
|
||||
|
|
|
@ -503,10 +503,8 @@ public class IdentifierUtilImpl implements IdentifierUtil, Configurable {
|
|||
}
|
||||
|
||||
|
||||
private boolean needsConversion(IdentifierConfiguration config) {
|
||||
return !(config.getLeadingDelimiter().equals(getIdentifierConfiguration().getLeadingDelimiter()) &&
|
||||
config.getTrailingDelimiter().equals(getIdentifierConfiguration().getTrailingDelimiter()) &&
|
||||
config.getIdentifierDelimiter().equals(getIdentifierConfiguration().getIdentifierDelimiter()));
|
||||
protected boolean needsConversion(IdentifierConfiguration config) {
|
||||
return !(config.getConversionKey().equals(getIdentifierConfiguration().getConversionKey()));
|
||||
}
|
||||
|
||||
private IdentifierRule[] getNamingRules(String[] rules) {
|
||||
|
|
|
@ -28,7 +28,8 @@ import org.apache.openjpa.lib.identifier.IdentifierUtil;
|
|||
public class IdConfigurationTestImpl implements IdentifierConfiguration {
|
||||
|
||||
Map<String, IdentifierRule> _rules = new HashMap<String, IdentifierRule>();
|
||||
|
||||
private final String conversionKey = getLeadingDelimiter() + getIdentifierDelimiter() + getTrailingDelimiter();
|
||||
|
||||
public IdConfigurationTestImpl() {
|
||||
_rules.put("DEFAULT", _defRule);
|
||||
}
|
||||
|
@ -84,4 +85,7 @@ public class IdConfigurationTestImpl implements IdentifierConfiguration {
|
|||
return true;
|
||||
}
|
||||
|
||||
public String getConversionKey() {
|
||||
return conversionKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ import org.apache.openjpa.lib.identifier.IdentifierUtil;
|
|||
public class NewIdConfigurationTestImpl implements IdentifierConfiguration {
|
||||
|
||||
Map<String, IdentifierRule> _rules = new HashMap<String, IdentifierRule>();
|
||||
|
||||
private final String conversionKey = getLeadingDelimiter() + getIdentifierDelimiter() + getTrailingDelimiter();
|
||||
|
||||
public NewIdConfigurationTestImpl() {
|
||||
_rules.put("DEFAULT", _defRule);
|
||||
}
|
||||
|
@ -84,4 +85,7 @@ public class NewIdConfigurationTestImpl implements IdentifierConfiguration {
|
|||
return true;
|
||||
}
|
||||
|
||||
public String getConversionKey() {
|
||||
return conversionKey;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue