本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: requiredSingle
import org.springframework.dao.support.DataAccessUtils; //导入方法依赖的package包/类
protected R requiredSingle(String sql, Object...args) {
return DataAccessUtils.requiredSingleResult(query(sql, args));
}
示例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)));
}