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


Java MapSqlParameterSource.addValue方法代碼示例

本文整理匯總了Java中org.springframework.jdbc.core.namedparam.MapSqlParameterSource.addValue方法的典型用法代碼示例。如果您正苦於以下問題:Java MapSqlParameterSource.addValue方法的具體用法?Java MapSqlParameterSource.addValue怎麽用?Java MapSqlParameterSource.addValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.jdbc.core.namedparam.MapSqlParameterSource的用法示例。


在下文中一共展示了MapSqlParameterSource.addValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createReferenceGenome

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
/**
 * Persists a {@code Reference} entity in database with a specified ID
 * @param reference to persist
 * @param referenceId ID for the reference
 * @return saved {@code Reference} instance
 */
@Transactional(propagation = Propagation.MANDATORY)
public Reference createReferenceGenome(final Reference reference, final long referenceId) {

    reference.setBioDataItemId(reference.getId());
    reference.setId(referenceId);

    final MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(GenomeParameters.REFERENCE_GENOME_ID.name(), reference.getId());
    params.addValue(GenomeParameters.BIO_DATA_ITEM_ID.name(), reference.getBioDataItemId());
    params.addValue(GenomeParameters.SIZE.name(), reference.getSize());
    params.addValue(GenomeParameters.INDEX_ID.name(), reference.getIndex().getId());
    params.addValue(GenomeParameters.GENE_ITEM_ID.name(), reference.getGeneFile() != null ?
                                                          reference.getGeneFile().getId() : null);

    getNamedParameterJdbcTemplate().update(createReferenceGenomeQuery, params);
    return reference;
}
 
開發者ID:epam,項目名稱:NGB,代碼行數:24,代碼來源:ReferenceGenomeDao.java

示例2: insertStatsDirLocalSize

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
@Override
@Transactional
public void insertStatsDirLocalSize(Map<Long, Long> dirLocalSize) throws SaodException {
	NamedParameterJdbcTemplate jdbcNamesTpl = new NamedParameterJdbcTemplate(this.jdbcTemplate);

	List<MapSqlParameterSource> batchArgs = new ArrayList<>();

	for (Entry<Long, Long> e : dirLocalSize.entrySet()) {
		MapSqlParameterSource parameters = new MapSqlParameterSource();
		parameters.addValue("node_id", e.getKey());
		parameters.addValue("local_size", e.getValue());
		batchArgs.add(parameters);
	}

	String query = sqlQueries.getQuery("insert_stats_dir_local_size.sql");
	jdbcNamesTpl.batchUpdate(query, batchArgs.toArray(new MapSqlParameterSource[dirLocalSize.size()]));
}
 
開發者ID:jeci-sarl,項目名稱:stats-alfresco-on-database,代碼行數:18,代碼來源:LocalDaoImpl.java

示例3: getLinkedTableParameters

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
/**
 * Creates a MapSqlParameterSource with common FeatureFile's ancestor's fields for future use in DB queries
 * @param idFieldName a name of ID fields of FeatureFile's ancestor's
 * @param featureFile a FeatureFile's ancestor's entity, which fields to add to parameters
 * @return a MapSqlParameterSource with common FeatureFile's ancestor's fields
 */
public static MapSqlParameterSource getLinkedTableParameters(String idFieldName, FeatureFile featureFile) {
    MapSqlParameterSource params = new MapSqlParameterSource();

    params.addValue(idFieldName, featureFile.getId());
    params.addValue(BiologicalDataItemParameters.BIO_DATA_ITEM_ID.name(), featureFile.getBioDataItemId());
    params.addValue(REFERENCE_GENOME_ID.name(), featureFile.getReferenceId());
    params.addValue(INDEX_ID.name(), featureFile.getIndex() != null ? featureFile.getIndex().getId() : null);
    params.addValue(COMPRESSED.name(), featureFile.getCompressed());

    if (featureFile instanceof GeneFile) {
        GeneFile geneFile = (GeneFile) featureFile;
        params.addValue(EXTERNAL_DB_TYPE_ID.name(), geneFile.getExternalDBType() != null ?
                geneFile.getExternalDBType().getId() : null);
        params.addValue(EXTERNAL_DB_ID.name(), geneFile.getExternalDB() != null ?
                geneFile.getExternalDB().getId() : null);
        params.addValue(EXTERNAL_DB_ORGANISM.name(), geneFile.getExternalDBOrganism());
    }

    return params;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:27,代碼來源:BiologicalDataItemDao.java

示例4: getParameters

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
private static MapSqlParameterSource[] getParameters(List<BiologicalDataItem> items, long bookmarkId, DaoHelper
        daoHelper, String bookmarkItemSequenceName) {
    MapSqlParameterSource[] params = new MapSqlParameterSource[items.size()];

    List<Long> ids = daoHelper.createIds(bookmarkItemSequenceName, items.size());

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

        param.addValue(BOOKMARK_ITEM_ID.name(), ids.get(i));
        param.addValue(BOOKMARK_ID.name(), bookmarkId);
        param.addValue(BIOLOGICAL_ITEM_ID.name(), BiologicalDataItem.getBioDataItemId(
                items.get(i)));

        params[i] = param;
    }

    return params;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:20,代碼來源:BookmarkDao.java

示例5: getParamSource

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
@Override
public MapSqlParameterSource getParamSource(W segment, Timestamp now) throws SQLException {
	MapSqlParameterSource args = new MapSqlParameterSource();
	args.addValue("id", segment.getId());
	args.addValue("geometry","SRID=4326;"+wktWriter.write(segment.getGeometry()));
	args.addValue("name", segment.getName());
	args.addValue("length", segment.getLength());
	args.addValue("streetType", segment.getStreetType());
	args.addValue("wayId", segment.getWayId());
	args.addValue("startNodeId", segment.getStartNodeId());
	args.addValue("startNodeIndex", segment.getStartNodeIndex());
	args.addValue("endNodeId", segment.getEndNodeId());
	args.addValue("endNodeIndex", segment.getEndNodeIndex());
	args.addValue("timestamp", now);
	args.addValue("tags", segment.getTags());		
	return args;
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:18,代碼來源:WayBaseGraphWriteDaoImpl.java

示例6: createTempList

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempList(final Long listId, final Collection<? extends BaseEntity> list) {
    Assert.notNull(listId);
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    // creates a new local temporary table if it doesn't exists to handle temporary lists
    getJdbcTemplate().update(createTemporaryListQuery);
    // fills in a temporary list by given values
    int i = 0;
    final Iterator<? extends BaseEntity> iterator = list.iterator();
    final MapSqlParameterSource[] batchArgs = new MapSqlParameterSource[list.size()];
    while (iterator.hasNext()) {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(HelperParameters.LIST_ID.name(), listId);
        params.addValue(HelperParameters.LIST_VALUE.name(), iterator.next().getId());
        batchArgs[i] = params;
        i++;
    }
    getNamedParameterJdbcTemplate().batchUpdate(insertTemporaryListItemQuery, batchArgs);
    return listId;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:21,代碼來源:DaoHelper.java

示例7: createSamples

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
/**
 * Saves sample metadata to the database.
 *
 * @param samples   {@code List&lt;Sample&gt;} samples to save
 * @param vcfFileId {@code long} file ID to save samples for
 */
@Transactional(propagation = Propagation.MANDATORY)
public void createSamples(List<VcfSample> samples, long vcfFileId) {
    List<Long> sampleIds = daoHelper.createIds(vcfSampleSequenceName, samples.size());
    for (int i = 0; i < samples.size(); i++) {
        samples.get(i).setId(sampleIds.get(i));
    }

    final List<MapSqlParameterSource> params = new ArrayList<>();
    for (VcfSample sample : samples) {

        MapSqlParameterSource param = new MapSqlParameterSource();
        param.addValue(SampleParameters.VCF_SAMPLE_ID.name(), sample.getId());
        param.addValue(SampleParameters.VCF_ID.name(), vcfFileId);
        param.addValue(SampleParameters.SAMPLE_NAME.name(), sample.getName());
        param.addValue(SampleParameters.ORDER_INDEX.name(), sample.getIndex());
        params.add(param);
    }

    getNamedParameterJdbcTemplate().batchUpdate(createSamplesForFileQuery, params.toArray(new
            MapSqlParameterSource[params.size()]));
}
 
開發者ID:epam,項目名稱:NGB,代碼行數:28,代碼來源:VcfFileDao.java

示例8: createSamples

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
/**
 * Saves sample metadata to the database.
 *
 * @param samples   {@code List&lt;Sample&gt;} samples to save
 * @param segFileId {@code long} file ID to save samples for
 */
@Transactional(propagation = Propagation.MANDATORY)
public void createSamples(List<SegSample> samples, long segFileId) {
    List<Long> sampleIds = daoHelper.createIds(segSampleSequenceName, samples.size());
    for (int i = 0; i < samples.size(); i++) {
        samples.get(i).setId(sampleIds.get(i));
    }

    final List<MapSqlParameterSource> params = new ArrayList<>();
    for (SegSample sample : samples) {

        MapSqlParameterSource param = new MapSqlParameterSource();
        param.addValue(SegSampleParameters.SEG_SAMPLE_ID.name(), sample.getId());
        param.addValue(SegSampleParameters.SEG_ID.name(), segFileId);
        param.addValue(SegSampleParameters.SAMPLE_NAME.name(), sample.getName());
        params.add(param);
    }

    getNamedParameterJdbcTemplate().batchUpdate(createSamplesForFileQuery, params.toArray(new
            MapSqlParameterSource[params.size()]));
}
 
開發者ID:epam,項目名稱:NGB,代碼行數:27,代碼來源:SegFileDao.java

示例9: createTempStringList

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempStringList(final Long listId, final Collection<String> list) {
    Assert.notNull(listId);
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    // creates a new local temporary table if it doesn't exists to handle temporary lists
    getJdbcTemplate().update(createTemporaryStringListQuery);
    // fills in a temporary list by given values
    int i = 0;
    final Iterator<String> iterator = list.iterator();
    final MapSqlParameterSource[] batchArgs = new MapSqlParameterSource[list.size()];
    while (iterator.hasNext()) {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(HelperParameters.LIST_ID.name(), listId);
        params.addValue(HelperParameters.LIST_VALUE.name(), iterator.next());
        batchArgs[i] = params;
        i++;
    }
    getNamedParameterJdbcTemplate().batchUpdate(insertTemporaryStringListItemQuery, batchArgs);
    return listId;
}
 
開發者ID:epam,項目名稱:NGB,代碼行數:21,代碼來源:DaoHelper.java

示例10: saveChromosomes

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
/**
 * Saves {@code List} of {@code Chromosome} entities with a specified ID in the database
 * as one reference
 * @param referenceId for the chromosomes
 * @param chromosomes {@code List} of {@code Chromosome} entities to store int the database
 * @return an array containing the numbers of rows affected by each update in the batch
 */
@Transactional(propagation = Propagation.MANDATORY)
public int[] saveChromosomes(final Long referenceId, final List<Chromosome> chromosomes) {
    final int count = chromosomes.size();
    final List<Long> chromosomeIds = daoHelper.createIds(chromosomeSequenceName, count);
    final MapSqlParameterSource[] batchArgs = new MapSqlParameterSource[count];
    for (int i = 0; i < count; i++) {
        final Chromosome chromosome = chromosomes.get(i);
        chromosome.setId(chromosomeIds.get(i));
        chromosome.setReferenceId(referenceId);
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(GenomeParameters.NAME.name(), chromosome.getName());
        params.addValue(GenomeParameters.SIZE.name(), chromosome.getSize());
        params.addValue(GenomeParameters.PATH.name(), chromosome.getPath());
        params.addValue(GenomeParameters.HEADER.name(), chromosome.getHeader());
        params.addValue(GenomeParameters.CHROMOSOME_ID.name(), chromosome.getId());
        params.addValue(GenomeParameters.REFERENCE_GENOME_ID.name(), chromosome.getReferenceId());
        batchArgs[i] = params;
    }
    return getNamedParameterJdbcTemplate().batchUpdate(createChromosomeQuery, batchArgs);
}
 
開發者ID:epam,項目名稱:NGB,代碼行數:28,代碼來源:ReferenceGenomeDao.java

示例11: loadFilesByNameStrict

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
/**
 * Finds files with a specified file name, checks name for strict, case sensitive equality
 * @param name search query
 * @return {@code List} of files with a matching name
 */
@Transactional(propagation = Propagation.MANDATORY)
public List<BiologicalDataItem> loadFilesByNameStrict(final String name) {
    final MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(BiologicalDataItemParameters.NAME.name(), name);
    return getNamedParameterJdbcTemplate().query(loadBiologicalDataItemsByNameStrictQuery,
            params, getRowMapper());
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:13,代碼來源:BiologicalDataItemDao.java

示例12: getParameters

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
static MapSqlParameterSource getParameters(Project project, Long parentId) {
    MapSqlParameterSource params = new MapSqlParameterSource();

    params.addValue(PROJECT_ID.name(), project.getId());
    params.addValue(PROJECT_NAME.name(), project.getName());
    params.addValue(CREATED_BY.name(), project.getCreatedBy());
    params.addValue(CREATED_DATE.name(), project.getCreatedDate());
    params.addValue(PARENT_ID.name(), parentId);

    return params;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:12,代碼來源:ProjectDao.java

示例13: deleteProjectItem

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的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

示例14: assignImpactDataset

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
private static ImpactDataset assignImpactDataset(String idurn) {
    int level = Integer.parseInt(idurn.substring(0, idurn.indexOf("****")));
    String urn = idurn.substring(idurn.indexOf("****") + 4);
    ImpactDataset impD = new ImpactDataset();

    Map<String, Object> row = null;
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("urn", urn);
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());

    try {
        row = namedParameterJdbcTemplate.queryForMap(GET_DATA_ATTR, parameters);
    } catch (IncorrectResultSizeDataAccessException irsdae) {
        Logger.error("Incorrect result size ", irsdae);
    } catch (DataAccessException dae) {
        Logger.error("SQL query failed ", dae);
    }

    impD.urn = urn;
    impD.level = level;
    impD.name = (String) row.get("name");
    impD.id = (Long) row.get("id");
    impD.datasetUrl = "#/datasets/" + impD.id;
    JsonNode prop = Json.parse((String) row.get("properties"));
    if (prop.has("valid") && (prop.get("valid").asText()) == "true") {
        impD.isValidDataset = true;
    } else {
        impD.isValidDataset = false;
    }
    return impD;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:32,代碼來源:LineageDAOLite.java

示例15: createReferenceGenome

import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; //導入方法依賴的package包/類
@Transactional(propagation = Propagation.MANDATORY)
public Reference createReferenceGenome(final Reference reference) {
    final MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(GenomeParameters.REFERENCE_GENOME_ID.name(), reference.getId());
    params.addValue(GenomeParameters.BIO_DATA_ITEM_ID.name(), reference.getBioDataItemId());
    params.addValue(GenomeParameters.SIZE.name(), reference.getSize());
    params.addValue(GenomeParameters.INDEX_ID.name(), reference.getIndex().getId());
    params.addValue(GenomeParameters.GENE_ITEM_ID.name(), reference.getGeneFile() != null ?
            reference.getGeneFile().getId() : null);

    getNamedParameterJdbcTemplate().update(createReferenceGenomeQuery, params);
    return reference;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:14,代碼來源:ReferenceGenomeDao.java


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