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


Java DataAccessUtils.requiredSingleResult方法代码示例

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


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

示例1: doDataSourceHealthCheck

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
private void doDataSourceHealthCheck(Health.Builder builder) throws Exception {
	String product = getProduct();
	builder.up().withDetail("database", product);
	String validationQuery = getValidationQuery(product);
	if (StringUtils.hasText(validationQuery)) {
		try {
			// Avoid calling getObject as it breaks MySQL on Java 7
			List<Object> results = this.jdbcTemplate.query(validationQuery,
					new SingleColumnRowMapper());
			Object result = DataAccessUtils.requiredSingleResult(results);
			builder.withDetail("hello", result);
		}
		catch (Exception ex) {
			builder.down(ex);
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:DataSourceHealthIndicator.java

示例2: selectMap

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <K, V> Map<K, V> selectMap(String statement, Object parameter,
                                  String mapKey, RowBounds rowBounds) {
    final List<?> list = selectList(statement, parameter, rowBounds);
    if (list == null || list.size() == 0) {
        return new HashMap<K, V>();
    }
    if (mapKey == null) {
        return (Map<K, V>) DataAccessUtils.requiredSingleResult(list);
    }
    ObjectFactory objectFactory = configuration.getObjectFactory();
    Map<K, V> selectedMap = objectFactory.create(Map.class);
    for (Object o : list) {
        V value = (V) o;
        MetaObject mo = MetaObject.forObject(o, objectFactory);
        final K key = (K) mo.getValue(mapKey);
        selectedMap.put(key, value);
    }
    return selectedMap;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:21,代码来源:DefaultSqlDataAccess.java

示例3: queryForObject

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
@Override
public <T> T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper<T> rowMapper)
		throws DataAccessException {

	List<T> results = query(sql, args, argTypes, new RowMapperResultSetExtractor<T>(rowMapper, 1));
	return DataAccessUtils.requiredSingleResult(results);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:JdbcTemplate.java

示例4: queryForObject

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, RowMapper<T> rowMapper)
		throws DataAccessException {

	List<T> results = getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rowMapper);
	return DataAccessUtils.requiredSingleResult(results);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:NamedParameterJdbcTemplate.java

示例5: getDefinition

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
@Override
public NumberingDefinition getDefinition(String numberName) {
	SQLQuery query = createBaseQuery(numberName);
	List<NumberingDefinition> list = queryDslJdbcOperations.query(query, new QBean<NumberingDefinition>(
			NumberingDefinition.class, nm.template, nm.minValue, nm.maxValue));
	return DataAccessUtils.requiredSingleResult(list);
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:8,代码来源:NumberingStoreImpl.java

示例6: getDefinition

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
@Override
public NumberingDefinition getDefinition(String numberName) {
	SQLQuery query = createBaseQuery(numberName);
	List<NumberingDefinition> list = query.list(new QBean<NumberingDefinition>(NumberingDefinition.class,
			nm.template, nm.minValue, nm.maxValue));
	return DataAccessUtils.requiredSingleResult(list);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:8,代码来源:NumberingStoreImpl.java

示例7: executeForObject

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T> T executeForObject(LineMapper<T> lineMapper, RpcRequest request) throws DataAccessException {
    List<T> results = execute(lineMapper, request);
    return DataAccessUtils.requiredSingleResult(results);
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:9,代码来源:RpcTemplate.java

示例8: queryForObject

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
public <T> T queryForObject(String sql, RowMapper<T> rowMapper) throws DataAccessException {
	List<T> results = query(sql, rowMapper);
	return DataAccessUtils.requiredSingleResult(results);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:5,代码来源:JdbcTemplate.java

示例9: queryForObject

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
public <T> T queryForObject(String sql, SqlParameterSource paramSource, RowMapper<T> rowMapper)
		throws DataAccessException {

	List<T> results = getJdbcOperations().query(getPreparedStatementCreator(sql, paramSource), rowMapper);
	return DataAccessUtils.requiredSingleResult(results);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:NamedParameterJdbcTemplate.java

示例10: getDefinition

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
@Override
public NumberingDefinition getDefinition(String numberName) {
	List<NumberingDefinition> list = baseQuery(numberName).list(
			new QBean<>(NumberingDefinition.class, nm.template, nm.minValue, nm.maxValue));
	return DataAccessUtils.requiredSingleResult(list);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:7,代码来源:NumberingStoreImpl.java

示例11: requiredSingle

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
protected R requiredSingle(String sql, Object...args) {
    return DataAccessUtils.requiredSingleResult(query(sql, args));
}
 
开发者ID:huherto,项目名称:springyRecords,代码行数:4,代码来源:AbstractBaseTable.java

示例12: queryForObject

import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
private <T> T queryForObject(String sql, PreparedStatementSetter setter, RowMapper<T> rowMapper) throws DataAccessException {
    return DataAccessUtils.requiredSingleResult(jdbc().query(sql, setter, new RowMapperResultSetExtractor<T>(rowMapper, 1)));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:4,代码来源:JdbcWebOutageRepository.java


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