当前位置: 首页>>代码示例>>Java>>正文


Java SingleColumnRowMapper类代码示例

本文整理汇总了Java中org.springframework.jdbc.core.SingleColumnRowMapper的典型用法代码示例。如果您正苦于以下问题:Java SingleColumnRowMapper类的具体用法?Java SingleColumnRowMapper怎么用?Java SingleColumnRowMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SingleColumnRowMapper类属于org.springframework.jdbc.core包,在下文中一共展示了SingleColumnRowMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addProjectItem

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Adds an item to a project, specified by ID
 * @param projectId {@code Long} ID of a project
 * @param biologicalItemId {@code Long} ID of an item to add
 */
@Transactional(propagation = Propagation.MANDATORY)
public void addProjectItem(long projectId, long biologicalItemId) {
    Project project = loadProject(projectId);
    Assert.notNull(project, MessageHelper.getMessage(MessagesConstants.ERROR_PROJECT_NOT_FOUND, projectId));

    long newId = daoHelper.createId(projectItemSequenceName);

    Number countNumber = getJdbcTemplate().queryForObject(loadProjectItemsMaxNumberQuery,
                                                          new SingleColumnRowMapper<>(), projectId);
    Integer count = 1;
    if (countNumber != null) {
        count = countNumber.intValue() + 1;
    }

    MapSqlParameterSource params = new MapSqlParameterSource();

    params.addValue(ProjectItemParameters.PROJECT_ITEM_ID.name(), newId);
    params.addValue(ProjectItemParameters.PROJECT_ID.name(), projectId);
    params.addValue(ProjectItemParameters.BIO_DATA_ITEM_ID.name(), biologicalItemId);
    params.addValue(ProjectItemParameters.ORDINAL_NUMBER.name(), count);
    params.addValue(ProjectItemParameters.HIDDEN.name(), false);

    getNamedParameterJdbcTemplate().update(addProjectItemQuery, params);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:30,代码来源:ProjectDao.java

示例2: queryForList

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
public <T> List<T> queryForList(String sql,Map<String,?> parameters, final int maxrows){
 	final RowMapper<T> mapper=new SingleColumnRowMapper<T>();
 	return this.namedParameterJdbcTemplate.query(sql, parameters, new ResultSetExtractor<List<T>>(){
@Override
public List<T> extractData(ResultSet rs) throws SQLException,
		DataAccessException {
	List<T> data = new ArrayList<T>();
       if(rs==null) return data;
       int rowNum = 0;
       while((maxrows>0 && rowNum<maxrows || maxrows<0) && rs.next()){
       	data.add(mapper.mapRow(rs, rowNum++));
       }
       return data;
}
 	});
 }
 
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:17,代码来源:RDBMS.java

示例3: findSchemas

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * !!! Only supports MySQL
 */
@SuppressWarnings("unchecked")
public static List<String> findSchemas(JdbcTemplate jdbcTemplate, final String schemaPattern) {
    try {
        if (StringUtils.isEmpty(schemaPattern)) {
            return jdbcTemplate.query("show databases", new SingleColumnRowMapper(String.class));
        }
        return jdbcTemplate.query("show databases like ?",
            new Object[] { schemaPattern },
            new SingleColumnRowMapper(String.class));
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return new ArrayList<String>();
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:18,代码来源:DdlUtils.java

示例4: getRowMapper

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
private <S> RowMapper<S> getRowMapper(JdbcTemplateQueryMethod queryMethod, Class<S> resultType) {
    if (queryMethod.isSingleColumn()) {
        return SingleColumnRowMapper.newInstance(resultType);
    } else {
        return getEntityRowMapper(queryMethod, resultType);
    }
}
 
开发者ID:cybozu,项目名称:spring-data-jdbc-template,代码行数:8,代码来源:JdbcTemplateRepositoryQuery.java

示例5: addProjectItems

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Adds multiple items to a project, specified by ID
 * @param projectId {@code Long} ID of a project
 * @param items a {@code List&lt;BiologicalDataItem&gt;} of items to add
 */
@Transactional(propagation = Propagation.MANDATORY)
public void addProjectItems(long projectId, List<ProjectItem> items) {
    Project project = loadProject(projectId);
    Assert.notNull(project, MessageHelper.getMessage(MessagesConstants.ERROR_PROJECT_NOT_FOUND, projectId));

    List<Long> newIds = daoHelper.createIds(projectItemSequenceName, items.size());

    Number countNumber = getJdbcTemplate().queryForObject(loadProjectItemsMaxNumberQuery,
                                                    new SingleColumnRowMapper<>(), projectId);
    Integer count = 1;
    if (countNumber != null) {
        count = countNumber.intValue() + 1;
    }

    ArrayList<MapSqlParameterSource> params = new ArrayList<>(items.size());
    for (int i = 0; i < items.size(); i++) {
        MapSqlParameterSource param = new MapSqlParameterSource();

        param.addValue(ProjectItemParameters.PROJECT_ITEM_ID.name(), newIds.get(i));
        param.addValue(ProjectItemParameters.PROJECT_ID.name(), projectId);
        param.addValue(ProjectItemParameters.BIO_DATA_ITEM_ID.name(),
                getBioDataItemId(items.get(i).getBioDataItem()));
        param.addValue(ProjectItemParameters.ORDINAL_NUMBER.name(), count);
        param.addValue(ProjectItemParameters.HIDDEN.name(), items.get(i).getHidden() != null &&
                items.get(i).getHidden());

        params.add(param);
    }

    getNamedParameterJdbcTemplate().batchUpdate(addProjectItemQuery,
            params.toArray(new MapSqlParameterSource[items.size()]));
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:38,代码来源:ProjectDao.java

示例6: deleteProjectItem

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Removes an item from a project, specified by ID
 * @param projectId {@code Long} ID of a project
 * @param biologicalItemId {@code Long} ID of an item to remove
 */
@Transactional(propagation = Propagation.MANDATORY)
public void deleteProjectItem(long projectId, long biologicalItemId) {
    List<Long> currentItemIds = getJdbcTemplate().query(loadProjectItemsIdsQuery, new SingleColumnRowMapper<>(),
            projectId);

    currentItemIds.remove(biologicalItemId);

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(ProjectItemParameters.PROJECT_ID.name(), projectId);
    params.addValue(ProjectItemParameters.BIO_DATA_ITEM_ID.name(), biologicalItemId);

    getNamedParameterJdbcTemplate().update(deleteProjectItemQuery, params);

    ArrayList<MapSqlParameterSource> updateParams = new ArrayList<>();
    for (int i = 1; i <= currentItemIds.size(); i++) {
        MapSqlParameterSource param = new MapSqlParameterSource();
        param.addValue(ProjectItemParameters.PROJECT_ID.name(), projectId);
        param.addValue(ProjectItemParameters.BIO_DATA_ITEM_ID.name(), currentItemIds.get(i - 1));
        param.addValue(ProjectItemParameters.ORDINAL_NUMBER.name(), i);

        updateParams.add(param);
    }

    getNamedParameterJdbcTemplate().batchUpdate(updateProjectItemOrderingNumberQuery, updateParams.toArray(
            new MapSqlParameterSource[updateParams.size()]));
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:32,代码来源:ProjectDao.java

示例7: isProjectItemHidden

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Tests if project item from a database is hidden
 * @param projectId {@code Long} ID of a project
 * @param biologicalItemId {@code Long} ID of an item to test
 * @return {@code true} if project item is hidden, {@code false} if not
 */
@Transactional(propagation = Propagation.MANDATORY)
public Boolean isProjectItemHidden(long projectId, long biologicalItemId) {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(ProjectItemParameters.PROJECT_ID.name(), projectId);
    params.addValue(ProjectItemParameters.BIO_DATA_ITEM_ID.name(), biologicalItemId);

    return getNamedParameterJdbcTemplate().queryForObject(isProjectItemHiddenQuery, params,
            new SingleColumnRowMapper<>());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:16,代码来源:ProjectDao.java

示例8: hasThisName

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Checks whether BAM file with a given name is already registered in the system.
 * @param name BAM file name
 * @return true, is file is already registered otherwise false
 */
@Transactional(propagation = Propagation.MANDATORY)
public Boolean hasThisName(String name) {
    List<String> names = getJdbcTemplate().query(searchByNameBamFileQuery,
            new SingleColumnRowMapper<>(), name);
    return names.isEmpty();
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:12,代码来源:BamFileDao.java

示例9: isProjectItemHidden

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Tests if project item from a database is hidden
 * @param projectId {@code Long} ID of a project
 * @param biologicalItemId {@code Long} ID of an item to test
 * @return {@code true} if project item is hidden, {@code false} if not
 */
@Transactional(propagation = Propagation.SUPPORTS)
public Boolean isProjectItemHidden(long projectId, long biologicalItemId) {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(ProjectItemParameters.PROJECT_ID.name(), projectId);
    params.addValue(ProjectItemParameters.BIO_DATA_ITEM_ID.name(), biologicalItemId);

    return getNamedParameterJdbcTemplate().queryForObject(isProjectItemHiddenQuery, params,
            new SingleColumnRowMapper<>());
}
 
开发者ID:epam,项目名称:NGB,代码行数:16,代码来源:ProjectDao.java

示例10: hasThisName

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
/**
 * Checks whether BAM file with a given name is already registered in the system.
 * @param name BAM file name
 * @return true, is file is already registered otherwise false
 */
@Transactional(propagation = Propagation.SUPPORTS)
public Boolean hasThisName(String name) {
    List<String> names = getJdbcTemplate().query(searchByNameBamFileQuery,
            new SingleColumnRowMapper<>(), name);
    return names.isEmpty();
}
 
开发者ID:epam,项目名称:NGB,代码行数:12,代码来源:BamFileDao.java

示例11: getLogEntriesAsGeoJson

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
@Override
public List<String> getLogEntriesAsGeoJson(LatLngBounds bounds) {
    String sql = "select ST_AsGeoJSON(location) geojson " +
            " from logs.client_location_log " +
            " where logs.client_location_log.location && st_makeenvelope(?, ?, ?, ?) " +
            " order by stamp desc limit 5000 ";
    return jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class),
            bounds.getSouthwest().getLng(),
            bounds.getSouthwest().getLat(),
            bounds.getNortheast().getLng(),
            bounds.getNortheast().getLat()
    );
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:14,代码来源:StatsLogDaoJdbc.java

示例12: intervalActivityIdReader

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
private ItemReader<Long> intervalActivityIdReader(Date cutOffDate, Class<?> activityClass, int chunkSize)
{
	try
	{
		JdbcPagingItemReader<Long> reader = new JdbcPagingItemReader<>();
		final SqlPagingQueryProviderFactoryBean sqlPagingQueryProviderFactoryBean = new SqlPagingQueryProviderFactoryBean();
		sqlPagingQueryProviderFactoryBean.setDataSource(dataSource);
		sqlPagingQueryProviderFactoryBean.setSelectClause("select id");
		sqlPagingQueryProviderFactoryBean.setFromClause("from interval_activities");
		sqlPagingQueryProviderFactoryBean.setWhereClause("where dtype = '" + activityClass.getSimpleName()
				+ "' and aggregates_computed = 0 and start_date <= :cutOffDate");
		sqlPagingQueryProviderFactoryBean.setSortKey("id");
		reader.setQueryProvider(sqlPagingQueryProviderFactoryBean.getObject());
		reader.setDataSource(dataSource);
		reader.setPageSize(chunkSize);
		reader.setRowMapper(SingleColumnRowMapper.newInstance(Long.class));
		reader.setParameterValues(Collections.singletonMap("cutOffDate", cutOffDate));
		reader.afterPropertiesSet();
		reader.setSaveState(true);
		logger.info("Reading nonaggregated {} entities with startDate <= {} in chunks of {}", activityClass.getSimpleName(),
				cutOffDate, chunkSize);
		return reader;
	}
	catch (Exception e)
	{
		throw YonaException.unexpected(e);
	}

}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:30,代码来源:ActivityAggregationBatchJob.java

示例13: querySingleColumn

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
@Override
public <E> List<E> querySingleColumn(QueryExample example,
                                     Class<E> elementType) {
    Validate.notNull(example);
    Validate.notEmpty(example.getFields(), "fields cannot be null");
    Transaction transaction = TransactionFactory.createQueryTransaction(config(), example, new SingleColumnRowMapper<E>(elementType));
    return transaction.execute();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:9,代码来源:AbstractDaoTemplate.java

示例14: listMessage

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
@Override
public List<Long> listMessage(LocalDateTime dtm) {
	QMailQueue a = new QMailQueue("a");
	SQLQuery query = queryDslJdbcOperations.newSqlQuery();
	query.from(a);
	query.where(a.scheduledAt.goe(dtm));
	query.where(a.deletedFlg.eq(DeletedFlag.NOT_DELETED.code()));
	return queryDslJdbcOperations.query(query, new SingleColumnRowMapper<Long>(Long.class), a.mailId);
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:10,代码来源:MessageStoreImpl.java

示例15: getFinishedExecStateIds

import org.springframework.jdbc.core.SingleColumnRowMapper; //导入依赖的package包/类
@Override
public Set<Long> getFinishedExecStateIds() {
	getFinishedExecStateIdsJDBCTemplate.setMaxRows(1000000);
	getFinishedExecStateIdsJDBCTemplate.setFetchSize(1000000);

	List<Long> result = doSelectWithTemplate(getFinishedExecStateIdsJDBCTemplate, SELECT_FINISHED_STEPS_IDS, new SingleColumnRowMapper<>(Long.class));

	return new HashSet<>(result);
}
 
开发者ID:CloudSlang,项目名称:score,代码行数:10,代码来源:ExecutionQueueRepositoryImpl.java


注:本文中的org.springframework.jdbc.core.SingleColumnRowMapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。