本文整理汇总了Java中org.springframework.jdbc.core.JdbcOperations.queryForList方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcOperations.queryForList方法的具体用法?Java JdbcOperations.queryForList怎么用?Java JdbcOperations.queryForList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.core.JdbcOperations
的用法示例。
在下文中一共展示了JdbcOperations.queryForList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMapList
import org.springframework.jdbc.core.JdbcOperations; //导入方法依赖的package包/类
/**
* return a map of the objects, divided into their transactions indexes.
*
* @param jdbcOperations
* the jdbc operations to use.
* @param sqlKey
* the sql key to use.
* @param sqlArgsBaList
* the byte arrays to use for SQL arguments.
* @param mapToObject
* the mapToObject to use.
* @param <T>
* the object type to use.
* @return a map of the objects, divided into their transactions indexes.
*/
private <T> Map<Integer, List<T>> getMapList(final JdbcOperations jdbcOperations, final String sqlKey,
final AbstractMapToObject<T> mapToObject, final byte[]... sqlArgsBaList) {
final String sql = getSql(sqlKey);
final List<Map<String, Object>> mapList = jdbcOperations.queryForList(sql, (Object[]) sqlArgsBaList);
final Map<Integer, List<T>> tMapList = new TreeMap<>();
for (final Map<String, Object> map : mapList) {
final byte[] transactionIndexBa = (byte[]) map.get(TRANSACTION_INDEX);
final T t = mapToObject.toObject(map);
final int transactionIndex = getTransactionIndex(transactionIndexBa);
if (!tMapList.containsKey(transactionIndex)) {
tMapList.put(transactionIndex, new ArrayList<>());
}
tMapList.get(transactionIndex).add(t);
}
return tMapList;
}
示例2: getCurrentSequence
import org.springframework.jdbc.core.JdbcOperations; //导入方法依赖的package包/类
/**
* Return current sequence.
*/
protected int getCurrentSequence(final String sequenceName, final JdbcOperations jdbcTemplate) {
final Long currentSequence;
final List<Long> sequence = jdbcTemplate
.queryForList("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME = ?", Long.class, sequenceName);
if (sequence.isEmpty()) {
// New sequence, start from an arbitrary sequence to be sure JIRA
// does not fill it
currentSequence = 10000L;
jdbcTemplate.update("INSERT INTO SEQUENCE_VALUE_ITEM (SEQ_NAME,SEQ_ID) values(?,?)", sequenceName,
currentSequence);
} else {
currentSequence = sequence.get(0);
}
return currentSequence.intValue();
}