當前位置: 首頁>>代碼示例>>Java>>正文


Java JdbcOperations.queryForList方法代碼示例

本文整理匯總了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;
}
 
開發者ID:coranos,項目名稱:neo-java,代碼行數:35,代碼來源:BlockDbH2Impl.java

示例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();
}
 
開發者ID:ligoj,項目名稱:plugin-bt-jira,代碼行數:19,代碼來源:JiraUpdateDao.java


注:本文中的org.springframework.jdbc.core.JdbcOperations.queryForList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。