当前位置: 首页>>代码示例>>Java>>正文


Java JdbcUtils.convertUnderscoreNameToPropertyName方法代码示例

本文整理汇总了Java中org.springframework.jdbc.support.JdbcUtils.convertUnderscoreNameToPropertyName方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcUtils.convertUnderscoreNameToPropertyName方法的具体用法?Java JdbcUtils.convertUnderscoreNameToPropertyName怎么用?Java JdbcUtils.convertUnderscoreNameToPropertyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jdbc.support.JdbcUtils的用法示例。


在下文中一共展示了JdbcUtils.convertUnderscoreNameToPropertyName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processDuplicateEntryException

import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
private void processDuplicateEntryException(Throwable t) throws FieldValidationException {
	DuplicateKeyException dke = ExceptionUtils.findExceptionOfType(t, DuplicateKeyException.class);
	if (dke == null) {
		return;
	}

	String constraint = DaoExceptionUtils.findViolatedConstraintName(dke);
	// Handle case when uuid is duplicated
	if (DaoExceptionUtils.MYSQL_CONSTRAINT_PRIMARY.equals(constraint)) {
		throw new IllegalArgumentException("Row with same primary key already exists", dke);
	}

	if (!constraint.contains(DaoExceptionUtils.MYSQL_CONSTRAINT_UNIQUE)) {
		throw new IllegalArgumentException("Constraint violation " + constraint, dke);
	}

	String fieldName = constraint.substring(0, constraint.indexOf(DaoExceptionUtils.MYSQL_CONSTRAINT_UNIQUE));
	if (fieldName.contains("_")) {
		fieldName = JdbcUtils.convertUnderscoreNameToPropertyName(fieldName);
	}

	throw new FieldValidationException(new DuplicateRecordValidationError(fieldName));
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:24,代码来源:EasyCrudDaoMySqlImpl.java

示例2: findTruncatedFieldNameIfAny

import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
public static String findTruncatedFieldNameIfAny(Throwable t) {
	DataTruncation exc = ExceptionUtils.findExceptionOfType(t, DataTruncation.class);
	if (exc == null) {
		return null;
	}

	String msg = exc.getMessage();
	if (!msg.contains("too long")) {
		return null;
	}

	String[] params = msg.split("\'");
	if (params.length < 2) {
		return null;
	}

	String fieldName = params[1];

	// Ok now convert it to camel case if needed
	if (fieldName.contains("_")) {
		fieldName = JdbcUtils.convertUnderscoreNameToPropertyName(fieldName);
	}

	return fieldName;
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:26,代码来源:DaoExceptionUtils.java

示例3: matchInParameterValuesWithInsertColumns

import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的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

示例4: sortAndTypeInParameter

import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的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

示例5: matchInParameterValuesWithInsertColumns

import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的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.support.JdbcUtils; //导入方法依赖的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.support.JdbcUtils; //导入方法依赖的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

示例8: sortAndTypeInParameter

import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的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:PkayJava,项目名称:pluggable,代码行数:49,代码来源:TableMetaDataContext.java


注:本文中的org.springframework.jdbc.support.JdbcUtils.convertUnderscoreNameToPropertyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。