本文整理匯總了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();
}