Polishing

This commit is contained in:
Juergen Hoeller 2018-01-09 22:20:22 +01:00
parent e43439c6c3
commit c8bdb3c602
4 changed files with 35 additions and 35 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -102,16 +102,13 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
private ResourceLoader resourceLoader = new DefaultResourceLoader(); private ResourceLoader resourceLoader = new DefaultResourceLoader();
/** Cache to hold filename lists per Locale */ /** Cache to hold filename lists per Locale */
private final ConcurrentMap<String, Map<Locale, List<String>>> cachedFilenames = private final ConcurrentMap<String, Map<Locale, List<String>>> cachedFilenames = new ConcurrentHashMap<>();
new ConcurrentHashMap<>();
/** Cache to hold already loaded properties per filename */ /** Cache to hold already loaded properties per filename */
private final ConcurrentMap<String, PropertiesHolder> cachedProperties = private final ConcurrentMap<String, PropertiesHolder> cachedProperties = new ConcurrentHashMap<>();
new ConcurrentHashMap<>();
/** Cache to hold merged loaded properties per locale */ /** Cache to hold merged loaded properties per locale */
private final ConcurrentMap<Locale, PropertiesHolder> cachedMergedProperties = private final ConcurrentMap<Locale, PropertiesHolder> cachedMergedProperties = new ConcurrentHashMap<>();
new ConcurrentHashMap<>();
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -400,7 +400,9 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
} }
@Override @Override
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) { public boolean needsReload(
String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) {
if (super.needsReload(baseName, locale, format, loader, bundle, loadTime)) { if (super.needsReload(baseName, locale, format, loader, bundle, loadTime)) {
cachedBundleMessageFormats.remove(bundle); cachedBundleMessageFormats.remove(bundle);
return true; return true;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,15 +56,15 @@ public class CallMetaDataContext {
/** Logger available to subclasses */ /** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());
/** name of procedure to call **/ /** Name of procedure to call **/
@Nullable @Nullable
private String procedureName; private String procedureName;
/** name of catalog for call **/ /** Name of catalog for call **/
@Nullable @Nullable
private String catalogName; private String catalogName;
/** name of schema for call **/ /** Name of schema for call **/
@Nullable @Nullable
private String schemaName; private String schemaName;
@ -274,7 +274,8 @@ public class CallMetaDataContext {
return new SqlOutParameter(parameterName, provider.getRefCursorSqlType(), rowMapper); return new SqlOutParameter(parameterName, provider.getRefCursorSqlType(), rowMapper);
} }
else { else {
throw new InvalidDataAccessApiUsageException("Return of a ResultSet from a stored procedure is not supported."); throw new InvalidDataAccessApiUsageException(
"Return of a ResultSet from a stored procedure is not supported.");
} }
} }
} }
@ -493,31 +494,37 @@ public class CallMetaDataContext {
} }
if (parameterName != null) { if (parameterName != null) {
if (parameterSource.hasValue(parameterName)) { if (parameterSource.hasValue(parameterName)) {
matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, parameterName)); matchedParameters.put(parameterName,
SqlParameterSourceUtils.getTypedValue(parameterSource, parameterName));
} }
else { else {
String lowerCaseName = parameterName.toLowerCase(); String lowerCaseName = parameterName.toLowerCase();
if (parameterSource.hasValue(lowerCaseName)) { if (parameterSource.hasValue(lowerCaseName)) {
matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName)); matchedParameters.put(parameterName,
SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName));
} }
else { else {
String englishLowerCaseName = parameterName.toLowerCase(Locale.ENGLISH); String englishLowerCaseName = parameterName.toLowerCase(Locale.ENGLISH);
if (parameterSource.hasValue(englishLowerCaseName)) { if (parameterSource.hasValue(englishLowerCaseName)) {
matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, englishLowerCaseName)); matchedParameters.put(parameterName,
SqlParameterSourceUtils.getTypedValue(parameterSource, englishLowerCaseName));
} }
else { else {
String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(parameterName); String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(parameterName);
if (parameterSource.hasValue(propertyName)) { if (parameterSource.hasValue(propertyName)) {
matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName)); matchedParameters.put(parameterName,
SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName));
} }
else { else {
if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) { if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
String sourceName = caseInsensitiveParameterNames.get(lowerCaseName); String sourceName = caseInsensitiveParameterNames.get(lowerCaseName);
matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName)); matchedParameters.put(parameterName,
SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
} }
else { else {
logger.warn("Unable to locate the corresponding parameter value for '" + parameterName + logger.warn("Unable to locate the corresponding parameter value for '" +
"' within the parameter values provided: " + caseInsensitiveParameterNames.values()); parameterName + "' within the parameter values provided: " +
caseInsensitiveParameterNames.values());
} }
} }
} }
@ -567,8 +574,8 @@ public class CallMetaDataContext {
value = ((SqlParameterValue)value).getValue(); value = ((SqlParameterValue)value).getValue();
} }
if (value != null) { if (value != null) {
logger.debug("Unable to locate the corresponding IN or IN-OUT parameter for \"" + parameterName + logger.debug("Unable to locate the corresponding IN or IN-OUT parameter for \"" +
"\" in the parameters used: " + callParameterNames.keySet()); parameterName + "\" in the parameters used: " + callParameterNames.keySet());
} }
} }
} }
@ -669,12 +676,7 @@ public class CallMetaDataContext {
* @since 4.2 * @since 4.2
*/ */
protected String createParameterBinding(SqlParameter parameter) { protected String createParameterBinding(SqlParameter parameter) {
if (isNamedBinding()) { return (isNamedBinding() ? parameter.getName() + " => ?" : "?");
return parameter.getName() + " => ?";
}
else {
return "?";
}
} }
private static String lowerCase(@Nullable String paramName) { private static String lowerCase(@Nullable String paramName) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -206,8 +206,8 @@ public class TableMetaDataContext {
*/ */
public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) { public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
List<Object> values = new ArrayList<>(); List<Object> values = new ArrayList<>();
// for parameter source lookups we need to provide caseinsensitive lookup support since the // For parameter source lookups we need to provide case-insensitive lookup support since the
// database metadata is not necessarily providing case sensitive column names // database metadata is not necessarily providing case-sensitive column names
Map<String, String> caseInsensitiveParameterNames = Map<String, String> caseInsensitiveParameterNames =
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource); SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
for (String column : this.tableColumns) { for (String column : this.tableColumns) {
@ -226,9 +226,8 @@ public class TableMetaDataContext {
} }
else { else {
if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) { if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
values.add( values.add(SqlParameterSourceUtils.getTypedValue(
SqlParameterSourceUtils.getTypedValue(parameterSource, parameterSource, caseInsensitiveParameterNames.get(lowerCaseName)));
caseInsensitiveParameterNames.get(lowerCaseName)));
} }
else { else {
values.add(null); values.add(null);