當前位置: 首頁>>代碼示例>>Java>>正文


Java SqlParameterSource.hasValue方法代碼示例

本文整理匯總了Java中org.springframework.jdbc.core.namedparam.SqlParameterSource.hasValue方法的典型用法代碼示例。如果您正苦於以下問題:Java SqlParameterSource.hasValue方法的具體用法?Java SqlParameterSource.hasValue怎麽用?Java SqlParameterSource.hasValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.jdbc.core.namedparam.SqlParameterSource的用法示例。


在下文中一共展示了SqlParameterSource.hasValue方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: matchInParameterValuesWithInsertColumns

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
@Override
public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
	/**
	 * 優先使用 EntityPropertySqlParameterSource
	 */
	if(parameterSource instanceof EntityPropertySqlParameterSource){
		List<Object> values = new ArrayList<Object>();
		for (String column : this.getTableColumns()) {
			if (parameterSource.hasValue(column)) {
				values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, column));
			}else{
				values.add(null);
			}
		}
		return values;
	}
	
	
	return super.matchInParameterValuesWithInsertColumns(parameterSource);
}
 
開發者ID:thinking-github,項目名稱:nbone,代碼行數:21,代碼來源:EntityTableMetaDataContext.java

示例2: matchInParameterValuesWithInsertColumns

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
/**
 * Match the provided column names and values with the list of columns used.
 * @param parameterSource the parameter names and values
 */
public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
	List<Object> values = new ArrayList<Object>();
	// for parameter source lookups we need to provide caseinsensitive lookup support since the
	// database metadata is not necessarily providing case sensitive column names
	Map<String, String> caseInsensitiveParameterNames =
			SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
	for (String column : this.tableColumns) {
		if (parameterSource.hasValue(column)) {
			values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, column));
		}
		else {
			String lowerCaseName = column.toLowerCase();
			if (parameterSource.hasValue(lowerCaseName)) {
				values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName));
			}
			else {
				String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(column);
				if (parameterSource.hasValue(propertyName)) {
					values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName));
				}
				else {
					if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
						values.add(
								SqlParameterSourceUtils.getTypedValue(parameterSource,
										caseInsensitiveParameterNames.get(lowerCaseName)));
					}
					else {
						values.add(null);
					}
				}
			}
		}
	}
	return values;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:40,代碼來源:TableMetaDataContext.java

示例3: sortAndTypeInParameter

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
/**
 * Match the provided column names and values with the list of columns used.
 * 
 * @param sqlParameterSource
 *            the parameter names and values
 * @param reconciledUpdatingColumns
 */
public List<Object> sortAndTypeInParameter(SqlParameterSource sqlParameterSource,
		List<String> reconciledUpdatingColumns) {
	List<Object> values = new ArrayList<Object>();
	// for parameter source lookups we need to provide caseinsensitive
	// lookup support since the
	// database metadata is not necessarily providing case sensitive column
	// names
	Map<?, ?> caseInsensitiveParameterNames = SqlParameterSourceUtils
			.extractCaseInsensitiveParameterNames(sqlParameterSource);
	for (String column : reconciledUpdatingColumns) {
		if (sqlParameterSource.hasValue(column)) {
			values.add(SqlParameterSourceUtils.getTypedValue(sqlParameterSource, column));
		} else {
			String lowerCaseName = column.toLowerCase();
			if (sqlParameterSource.hasValue(lowerCaseName)) {
				values.add(SqlParameterSourceUtils.getTypedValue(sqlParameterSource, lowerCaseName));
			} else {
				String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(column);
				if (sqlParameterSource.hasValue(propertyName)) {
					values.add(SqlParameterSourceUtils.getTypedValue(sqlParameterSource, propertyName));
				} else {
					if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
						values.add(SqlParameterSourceUtils.getTypedValue(sqlParameterSource,
								(String) caseInsensitiveParameterNames.get(lowerCaseName)));
					} else {
						values.add(null);
					}
				}
			}
		}
	}
	return values;
}
 
開發者ID:skarpushin,項目名稱:summerb,代碼行數:41,代碼來源:TableMetaDataContext.java

示例4: hasValue

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
@Override
public boolean hasValue(String paramName) {
	for (SqlParameterSource sqlParameterSource : parameterSources) {
		if (sqlParameterSource.hasValue(paramName)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:skarpushin,項目名稱:summerb,代碼行數:10,代碼來源:SqlParameterSourceMergedImpl.java

示例5: matchInParameterValuesWithInsertColumns

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
/**
 * Match the provided column names and values with the list of columns used.
 * @param parameterSource the parameter names and values
 */
public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
	List<Object> values = new ArrayList<Object>();
	// for parameter source lookups we need to provide caseinsensitive lookup support since the
	// database metadata is not necessarily providing case sensitive column names
	Map caseInsensitiveParameterNames =
			SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
	for (String column : this.tableColumns) {
		if (parameterSource.hasValue(column)) {
			values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, column));
		}
		else {
			String lowerCaseName = column.toLowerCase();
			if (parameterSource.hasValue(lowerCaseName)) {
				values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName));
			}
			else {
				String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(column);
				if (parameterSource.hasValue(propertyName)) {
					values.add(SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName));
				}
				else {
					if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
						values.add(
								SqlParameterSourceUtils.getTypedValue(parameterSource,
										(String) caseInsensitiveParameterNames.get(lowerCaseName)));
					}
					else {
						values.add(null);
					}
				}
			}
		}
	}
	return values;
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:40,代碼來源:TableMetaDataContext.java

示例6: matchInParameterValuesWithCallParameters

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
/**
 * Match input parameter values with the parameters declared to be used in the call.
 * @param parameterSource the input values
 * @return a Map containing the matched parameter names with the value taken from the input
 */
public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource) {
	// For parameter source lookups we need to provide case-insensitive lookup support
	// since the database metadata is not necessarily providing case sensitive parameter names.
	Map<String, String> caseInsensitiveParameterNames =
			SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);

	Map<String, String> callParameterNames = new HashMap<String, String>(this.callParameters.size());
	Map<String, Object> matchedParameters = new HashMap<String, Object>(this.callParameters.size());
	for (SqlParameter parameter : this.callParameters) {
		if (parameter.isInputValueProvided()) {
			String parameterName = parameter.getName();
			String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
			if (parameterNameToMatch != null) {
				callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName);
			}
			if (parameterName != null) {
				if (parameterSource.hasValue(parameterName)) {
					matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, parameterName));
				}
				else {
					String lowerCaseName = parameterName.toLowerCase();
					if (parameterSource.hasValue(lowerCaseName)) {
						matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName));
					}
					else {
						String englishLowerCaseName = parameterName.toLowerCase(Locale.ENGLISH);
						if (parameterSource.hasValue(englishLowerCaseName)) {
							matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, englishLowerCaseName));
						}
						else {
							String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(parameterName);
							if (parameterSource.hasValue(propertyName)) {
								matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName));
							}
							else {
								if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
									String sourceName = caseInsensitiveParameterNames.get(lowerCaseName);
									matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
								}
								else {
									logger.warn("Unable to locate the corresponding parameter value for '" + parameterName +
											"' within the parameter values provided: " + caseInsensitiveParameterNames.values());
								}
							}
						}
					}
				}
			}
		}
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Matching " + caseInsensitiveParameterNames.values() + " with " + callParameterNames.values());
		logger.debug("Found match for " + matchedParameters.keySet());
	}
	return matchedParameters;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:63,代碼來源:CallMetaDataContext.java

示例7: matchInParameterValuesWithCallParameters

import org.springframework.jdbc.core.namedparam.SqlParameterSource; //導入方法依賴的package包/類
/**
 * Match input parameter values with the parameters declared to be used in the call.
 * @param parameterSource the input values
 * @return a Map containing the matched parameter names with the value taken from the input
 */
public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource) {
	// For parameter source lookups we need to provide case-insensitive lookup support
	// since the database metadata is not necessarily providing case sensitive parameter names.
	Map caseInsensitiveParameterNames =
			SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);

	Map<String, String> callParameterNames = new HashMap<String, String>(this.callParameters.size());
	Map<String, Object> matchedParameters = new HashMap<String, Object>(this.callParameters.size());
	for (SqlParameter parameter : this.callParameters) {
		if (parameter.isInputValueProvided()) {
			String parameterName = parameter.getName();
			String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
			if (parameterNameToMatch != null) {
				callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName);
			}
			if (parameterName != null) {
				if (parameterSource.hasValue(parameterName)) {
					matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, parameterName));
				}
				else {
					String lowerCaseName = parameterName.toLowerCase();
					if (parameterSource.hasValue(lowerCaseName)) {
						matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, lowerCaseName));
					}
					else {
						String englishLowerCaseName = parameterName.toLowerCase(Locale.ENGLISH);
						if (parameterSource.hasValue(englishLowerCaseName)) {
							matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, englishLowerCaseName));
						}
						else {
							String propertyName = JdbcUtils.convertUnderscoreNameToPropertyName(parameterName);
							if (parameterSource.hasValue(propertyName)) {
								matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, propertyName));
							}
							else {
								if (caseInsensitiveParameterNames.containsKey(lowerCaseName)) {
									String sourceName = (String) caseInsensitiveParameterNames.get(lowerCaseName);
									matchedParameters.put(parameterName, SqlParameterSourceUtils.getTypedValue(parameterSource, sourceName));
								}
								else {
									logger.warn("Unable to locate the corresponding parameter value for '" + parameterName +
											"' within the parameter values provided: " + caseInsensitiveParameterNames.values());
								}
							}
						}
					}
				}
			}
		}
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Matching " + caseInsensitiveParameterNames.values() + " with " + callParameterNames.values());
		logger.debug("Found match for " + matchedParameters.keySet());
	}
	return matchedParameters;
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:63,代碼來源:CallMetaDataContext.java


注:本文中的org.springframework.jdbc.core.namedparam.SqlParameterSource.hasValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。