本文整理汇总了Java中org.springframework.jdbc.core.ColumnMapRowMapper类的典型用法代码示例。如果您正苦于以下问题:Java ColumnMapRowMapper类的具体用法?Java ColumnMapRowMapper怎么用?Java ColumnMapRowMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnMapRowMapper类属于org.springframework.jdbc.core包,在下文中一共展示了ColumnMapRowMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequestInternal
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String query = request.getParameter("query");
if (query != null) {
map.put("query", query);
try {
List<?> result = daoHelper.getJdbcTemplate().query(query, new ColumnMapRowMapper());
map.put("result", result);
} catch (DataAccessException x) {
map.put("error", ExceptionUtils.getRootCause(x).getMessage());
}
}
return new ModelAndView("db","model",map);
}
示例2: query
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<Map<String, Object>> query(String sql, Object[] args, AggregationDescriptor descriptor) {
Assert.notNull(sql, "sql must not be null");
Assert.notNull(descriptor, "AggregationDescriptor must not be null");
ShardOperationProcessor processor = null;
if (descriptor.needGroupBy() || descriptor.needAggregation()) {
processor = this.getAggregationProcessor(descriptor);
} else {
processor = this.getNonAggregationProcessor(new ColumnMapRowMapper());
}
List<Map<String, Object>> resultList = (List<Map<String, Object>>) this.process(sql, args, processor);
AggregationUtil.sortIfNecessary(descriptor, resultList);
return AggregationUtil.limitIfNecessary(descriptor, resultList);
}
示例3: JdbcTemplate
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@Test
public void test_不设i() {
JdbcTemplate jt = new JdbcTemplate(createGroupDataSource("ds0:rw, ds1:r, ds2:r, ds3:r"));
MockDataSource.clearTrace();
GroupDataSourceRouteHelper.executeByGroupDataSourceIndex(1);
jt.query("select 1 from dual", new Object[] {}, new ColumnMapRowMapper());
MockDataSource.showTrace();
Assert.assertTrue(MockDataSource.hasTrace("", "ds1", "select 1 from dual"));
MockDataSource.clearTrace();
GroupDataSourceRouteHelper.executeByGroupDataSourceIndex(2);
jt.query("select 1 from dual", new Object[] {}, new ColumnMapRowMapper());
MockDataSource.showTrace();
Assert.assertTrue(MockDataSource.hasTrace("", "ds2", "select 1 from dual"));
}
示例4: assertEventData
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
private void assertEventData(String title, String timeZone, String startTime, String endTime, String slug) {
Map<String, Object> externalEventData = jdbcTemplate.queryForObject("select event, sourceId, source from ExternalEvent where sourceId=? and source='NFJS'", new ColumnMapRowMapper(), SHOW_ID);
Long eventId = (Long) externalEventData.get("event");
assertEquals(Long.valueOf(1), eventId);
assertEquals(Long.valueOf(SHOW_ID), externalEventData.get("sourceId"));
assertEquals("NFJS", externalEventData.get("source"));
Map<String, Object> eventData = jdbcTemplate.queryForObject("select id, title, timeZone, startTime, endTime, slug, description, memberGroup from Event where id=?", new ColumnMapRowMapper(), eventId);
assertEquals(eventId, eventData.get("id"));
assertEquals(title, eventData.get("title"));
assertEquals(timeZone, eventData.get("timeZone"));
assertEquals(startTime, eventData.get("startTime").toString());
assertEquals(endTime, eventData.get("endTime").toString());
assertEquals(slug, eventData.get("slug"));
assertNull(eventData.get("description"));
assertEquals(1L, eventData.get("memberGroup"));
}
示例5: assertLeaderData
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
private void assertLeaderData(String name, String bio, String personalUrl, String twitterUsername) {
Map<String, Object> externalLeaderData = jdbcTemplate.queryForObject("select leader, sourceId, source from ExternalLeader where source='NFJS' and sourceId=?", new ColumnMapRowMapper(), 38);
Long leaderId = (Long) externalLeaderData.get("leader");
assertEquals(Long.valueOf(15), leaderId);
assertEquals(38L, externalLeaderData.get("sourceId"));
assertEquals("NFJS", externalLeaderData.get("source"));
Map<String, Object> leaderData = jdbcTemplate.queryForObject("select id, name, company, title, location, bio, personalUrl, companyUrl, twitterUsername, member from Leader where id=?", new ColumnMapRowMapper(), leaderId);
assertEquals(leaderId, leaderData.get("id"));
assertEquals(name, leaderData.get("name"));
assertNull(leaderData.get("company"));
assertNull(leaderData.get("title"));
assertNull(leaderData.get("location"));
assertEquals(bio, leaderData.get("bio").toString().trim());
assertEquals(personalUrl, leaderData.get("personalUrl"));
assertNull(leaderData.get("companyUrl"));
assertEquals(twitterUsername, leaderData.get("twitterUsername"));
assertNull(leaderData.get("member")); // TODO: Might want to figure out how to associate this with GH member table
}
示例6: createDefaultOutParameter
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@Override
public SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta) {
if (meta.getSqlType() == Types.OTHER && REF_CURSOR_NAME.equals(meta.getTypeName())) {
return new SqlOutParameter(parameterName, getRefCursorSqlType(), new ColumnMapRowMapper());
}
else {
return super.createDefaultOutParameter(parameterName, meta);
}
}
示例7: createDefaultOutParameter
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@Override
public SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta) {
if (meta.getSqlType() == Types.OTHER && "refcursor".equals(meta.getTypeName())) {
return new SqlOutParameter(parameterName, getRefCursorSqlType(), new ColumnMapRowMapper());
}
else {
return super.createDefaultOutParameter(parameterName, meta);
}
}
示例8: getColumnMapRowMapper
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@Override
protected RowMapper getColumnMapRowMapper() {
if("2".equals(EopSetting.DBTYPE)){
return new OracleColumnMapRowMapper();
}else if("1".equals(EopSetting.DBTYPE)){
return new MySqlColumnMapRowMapper();
}else{
return new ColumnMapRowMapper();
}
}
示例9: queryPageByMapMapperNativeSqlString
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
/**
* Map 包装
*/
public static PageBean queryPageByMapMapperNativeSqlString(final JdbcTemplate jdbcTemplate, final SqlUtils.Dialect dbDialect,
final String queryNativeSql, Object[] queryArgs,
final String countNativeSql, Object[] countArgs,
int currentPageNo, int pageSize) {
return queryPageByNativeSqlString(jdbcTemplate, dbDialect,
queryNativeSql, queryArgs,
countNativeSql, countArgs,
currentPageNo, pageSize, new ColumnMapRowMapper());
}
示例10: getColumnMapRowMapper
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
private RowMapper<Map<String, Object>> getColumnMapRowMapper() {
if (getKeyType().equalsIgnoreCase(LOWER_KEY)) {
return new MiniColumnMapRowMapper();
} else if (getKeyType().equalsIgnoreCase(UPPER_KEY)) {
return new ColumnMapRowMapper();
} else {
return new MiniColumnOriginalMapRowMapper();
}
}
示例11: getColumnMapRowMapper
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
/**
*根据参数设置map的key大小写
**/
private RowMapper<Map<String,Object>> getColumnMapRowMapper() {
if(getKeyType().equalsIgnoreCase(LOWER_KEY)){
return new MiniColumnMapRowMapper();
}else if(getKeyType().equalsIgnoreCase(UPPER_KEY)){
return new ColumnMapRowMapper();
}else{
return new MiniColumnOriginalMapRowMapper();
}
}
示例12: buildTableReader
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
/**
* @param tableName
* @param executionContext
* @return a JdbcCursorItemReader for the given table name. Override this method to alert the SQL statement that's
* used for a particular table.
*/
protected JdbcCursorItemReader<Map<String, Object>> buildTableReader(String tableName, ExecutionContext executionContext) {
JdbcCursorItemReader<Map<String, Object>> reader = new JdbcCursorItemReader<>();
reader.setDataSource(dataSource);
reader.setRowMapper(new ColumnMapRowMapper());
reader.setSql(getSqlQueryForTable(tableName));
reader.open(executionContext);
return reader;
}
示例13: iterator
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Iterator<RowMap> iterator(long first, long count) {
SelectCreator creator = selectCreator.clone();
applyFilters(creator);
applyQuickFilters(creator);
if (getSort() != null) {
creator.orderBy(getSort().getProperty(), getSort().isAscending());
}
if (getSecondarySort() != null) {
creator.orderBy(getSecondarySort().getProperty(), getSecondarySort().isAscending());
}
creator.orderBy(uniqueColumn);
log.debug("Executing query: " + creator);
JdbcTemplate t = new JdbcTemplate(getDataSource());
@SuppressWarnings("rawtypes")
RowMapper rowMapper = new ColumnMapRowMapper() {
@Override
protected Map<String, Object> createColumnMap(int columnCount) {
return new RowMap();
}
@Override
public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, Object> row = super.mapRow(rs, rowNum);
processRow((RowMap) row);
return row;
}
};
return t.query(creator.page(DIALECT, (int) count, (int) first), (RowMapper<RowMap>) rowMapper).iterator();
}
示例14: assertVenueData
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
private void assertVenueData(String name, String postalAddress, double latitude, double longitude, String locationHint, long createdBy) {
Map<String, Object> eventVenueData = jdbcTemplate.queryForObject("select event, venue from EventVenue where event=?", new ColumnMapRowMapper(), 1);
assertEquals(Long.valueOf(1), eventVenueData.get("event"));
Long venueId = (Long) eventVenueData.get("venue");
assertEquals(Long.valueOf(1), venueId);
Map<String, Object> venueData = jdbcTemplate.queryForObject("select id, name, postalAddress, latitude, longitude, locationHint, createdBy from Venue where id=?", new ColumnMapRowMapper(), venueId);
assertEquals(Long.valueOf(1), venueData.get("id"));
assertEquals(name, venueData.get("name"));
assertEquals(postalAddress, venueData.get("postalAddress"));
assertEquals(latitude, venueData.get("latitude"));
assertEquals(longitude, venueData.get("longitude"));
assertEquals(locationHint, venueData.get("locationHint"));
assertEquals(createdBy, venueData.get("createdBy"));
}
示例15: assertEventTimeSlotData
import org.springframework.jdbc.core.ColumnMapRowMapper; //导入依赖的package包/类
private void assertEventTimeSlotData(long id, long eventId, String label, String startTime, String endTime) {
Map<String, Object> externalEventTimeSlotData = jdbcTemplate.queryForObject("select timeSlot, sourceId, source from ExternalEventTimeSlot where timeSlot=?", new ColumnMapRowMapper(), id);
assertEquals(id, externalEventTimeSlotData.get("timeSlot"));
assertEquals(6311L, externalEventTimeSlotData.get("sourceId"));
assertEquals("NFJS", externalEventTimeSlotData.get("source"));
Map<String, Object> eventTimeSlotData = jdbcTemplate.queryForObject("select id, event, label, startTime, endTime from EventTimeSlot where id=?", new ColumnMapRowMapper(), 16);
assertEquals(id, eventTimeSlotData.get("id"));
assertEquals(eventId, eventTimeSlotData.get("event"));
assertEquals(label, eventTimeSlotData.get("label"));
assertEquals(startTime, eventTimeSlotData.get("startTime").toString());
assertEquals(endTime, eventTimeSlotData.get("endTime").toString());
}