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


Java NamedParameterJdbcTemplate類代碼示例

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


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

示例1: getTableNames

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
public static List<String> getTableNames(String scopes)
{
       //Logger.debug("Entering AdvSearch.java:getTableNames()");
	List<String> tables = null;
	if (StringUtils.isNotBlank(scopes))
	{
		String[] scopeArray = scopes.split(",");
		List<String> scopeList = Arrays.asList(scopeArray);
		Map<String, List> param = Collections.singletonMap("scopes", scopeList);
		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new
				NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());
		tables = namedParameterJdbcTemplate.queryForList(
				GET_DATASET_TABLE_NAMES_BY_SCOPE, param, String.class);
	}
	else
	{
		tables = getJdbcTemplate().queryForList(GET_DATASET_TABLE_NAMES, String.class);
	}

	return tables;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:22,代碼來源:AdvSearchDAO.java

示例2: assignData

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
private static void assignData(LineageNodeLite node) {
    List<Map<String, Object>> rows = null;
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("urn", node.urn);
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());

    rows = namedParameterJdbcTemplate.queryForList(GET_DATA_ATTR, parameters);

    for (Map<String, Object> row : rows) {
        // node only knows id, level, and urn, assign all other attributes
        JsonNode prop = Json.parse((String) row.get("properties"));
        node.description = (prop.has("description")) ? prop.get("description").asText() : "null";
        node.source = (String) row.get("source");
        node.storage_type = (String) row.get("dataset_type"); // what the js calls storage_type, the sql calls dataset_type
        node.dataset_type = (String) row.get("dataset_type");

        // check wh_property for a user specified color, use some generic defaults if nothing found
        //node.color = getColor(node.urn, node.node_type);

        //node.abstracted_path = getPostfix(node.urn);

        // set things to show up in tooltip
        node._sort_list.add("abstracted_path");
        node._sort_list.add("storage_type");
    }
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:27,代碼來源:LineageDAOLite.java

示例3: insertStatsDirLocalSize

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

示例4: selectparentFolders

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
@Override
@Transactional
public List<Long> selectparentFolders(List<Long> nodesid) throws SaodException {
	if (nodesid == null || nodesid.size() == 0) {
		return Collections.emptyList();
	}

	NamedParameterJdbcTemplate jdbcNamesTpl = new NamedParameterJdbcTemplate(this.jdbcTemplate);

	MapSqlParameterSource parameters = new MapSqlParameterSource();
	parameters.addValue("ids", nodesid);

	String query = sqlQueries.getQuery("select_parents_folders.sql");
	final SqlRowSet queryForRowSet = jdbcNamesTpl.queryForRowSet(query, parameters);

	final List<Long> ids = new ArrayList<>();
	while (queryForRowSet.next()) {
		ids.add(queryForRowSet.getLong(1));
	}

	return ids;
}
 
開發者ID:jeci-sarl,項目名稱:stats-alfresco-on-database,代碼行數:23,代碼來源:LocalDaoImpl.java

示例5: getFlowNames

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
public static List<String> getFlowNames(String applications)
{
       //ogger.debug("Entering AdvSearch.java:getFlowNames()");
	List<String> flowNames = null;
	if (StringUtils.isNotBlank(applications))
	{
		String[] appArray = applications.split(",");
		List<String> appList = Arrays.asList(appArray);
		Map<String, List> param = Collections.singletonMap("apps", appList);
		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new
				NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());
		flowNames = namedParameterJdbcTemplate.queryForList(
				GET_FLOW_NAMES_BY_APP, param, String.class);
	}
	else
	{
		flowNames = getJdbcTemplate().queryForList(GET_FLOW_NAMES, String.class);
	}

	return flowNames;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:22,代碼來源:AdvSearchDAO.java

示例6: assignApp

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
private static void assignApp(LineageNodeLite node) {
    List<Map<String, Object>> rows = null;
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("urn", node.urn);
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());

    rows = namedParameterJdbcTemplate.queryForList(GET_DATA_ATTR, parameters);

    for (Map<String, Object> row : rows) {
        // node only knows id, level, and urn, assign all other attributes

        // stored in dict_dataset, so has those fields
        JsonNode prop = Json.parse((String) row.get("properties"));

        // properties is a JsonNode, extract what we want out of it
        node.description = (prop.has("description")) ? prop.get("description").asText() : "null";
        node.app_code = (prop.has("app_code")) ? prop.get("app_code").asText() : "null";

        // check wh_property for a user specified color, use some generic defaults if nothing found
        //node.color = getColor(node.urn, node.node_type);

        // set things to show up in tooltip
        node._sort_list.add("app_code");
        node._sort_list.add("description");
    }
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:27,代碼來源:LineageDAOLite.java

示例7: assignDB

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
private static void assignDB(LineageNodeLite node) {
    List<Map<String, Object>> rows = null;
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("urn", node.urn);
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());

    rows = namedParameterJdbcTemplate.queryForList(GET_DATA_ATTR, parameters);
    // node only knows id, level, and urn, assign all other attributes

    for (Map<String, Object> row : rows) {
        JsonNode prop = Json.parse((String) row.get("properties"));
        node.description = (prop.has("description")) ? prop.get("description").asText() : "null";
        node.jdbc_url = (prop.has("jdbc_url")) ? prop.get("jdbc_url").asText() : "null";
        node.db_code = (prop.has("db_code")) ? prop.get("db_code").asText() : "null";

        // check wh_property for a user specified color, use some generic defaults if nothing found
        //node.color = getColor(node.urn, node.node_type);

        // set things to show up in tooltip
        node._sort_list.add("db_code");
        //node._sort_list.add("last_modified");
    }
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:24,代碼來源:LineageDAOLite.java

示例8: assignGeneral

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
private static void assignGeneral(LineageNodeLite node) {
    List<Map<String, Object>> rows = null;
    MapSqlParameterSource parameters = new MapSqlParameterSource();
    parameters.addValue("urn", node.urn);
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());

    rows = namedParameterJdbcTemplate.queryForList(GET_DATA_ATTR, parameters);


    for (Map<String, Object> row : rows) {
        node.name = (String) row.get("name");
        node.schema = (String) row.get("schema");

        // check wh_property for a user specified color, use some generic defaults if nothing found
        node.color = getNodeColor(node.urn, node.node_type);

        // set things to show up in tooltip
        node._sort_list.add("urn");
        node._sort_list.add("name");
    }
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:22,代碼來源:LineageDAOLite.java

示例9: create

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
/**
 * Creates a {@link QueryLookupStrategy} for the given {@link EntityManager}
 * and {@link Key}.
 *
 * @param em                        must not be {@literal null}.
 * @param key                       may be {@literal null}.
 * @param extractor                 must not be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @return
 */
public static QueryLookupStrategy create(Key key, EvaluationContextProvider evaluationContextProvider,
                                         SqlGenerator generator, NamedParameterJdbcTemplate template, RowMapper rowMapper,
                                         TableDescription tableDescription) {

    Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");

    switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
        case CREATE:
            return new CreateQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        case USE_DECLARED_QUERY:
            return new DeclaredQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        case CREATE_IF_NOT_FOUND:
            return new CreateIfNotFoundQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        default:
            throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
    }
}
 
開發者ID:rubasace,項目名稱:spring-data-jdbc,代碼行數:28,代碼來源:JdbcQueryLookupStrategy.java

示例10: getTargetRepository

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
    entityClass = metadata.getDomainType();
    @SuppressWarnings("rawtypes")
    ReflectionJdbcRepository repository = getTargetRepositoryViaReflection(metadata, entityClass);
    repository.setDataSource(datasource);
    repository.afterPropertiesSet();
    this.repository = repository;

    generator = SqlGeneratorFactory.getInstance().getGenerator(datasource);
    template = new NamedParameterJdbcTemplate((JdbcOperations) extractRepositoryField(repository, FIELD_JDBC_OPS));
    rowMapper = extractRepositoryField(repository, FIELD_ROWMAPPER);
    tableDescription = extractRepositoryField(repository, FIELD_TABLE_DESCRIPTION);

    return repository;
}
 
開發者ID:rubasace,項目名稱:spring-data-jdbc,代碼行數:17,代碼來源:JdbcRepositoryFactory.java

示例11: getTableNames

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
public static List<String> getTableNames(String scopes)
{
	List<String> tables = null;
	if (StringUtils.isNotBlank(scopes))
	{
		String[] scopeArray = scopes.split(",");
		List<String> scopeList = Arrays.asList(scopeArray);
		Map<String, List> param = Collections.singletonMap("scopes", scopeList);
		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new
				NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());
		tables = namedParameterJdbcTemplate.queryForList(
				GET_DATASET_TABLE_NAMES_BY_SCOPE, param, String.class);
	}
	else
	{
		tables = getJdbcTemplate().queryForList(GET_DATASET_TABLE_NAMES, String.class);
	}

	return tables;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:21,代碼來源:AdvSearchDAO.java

示例12: getFlowNames

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
public static List<String> getFlowNames(String applications)
{
	List<String> flowNames = null;
	if (StringUtils.isNotBlank(applications))
	{
		String[] appArray = applications.split(",");
		List<String> appList = Arrays.asList(appArray);
		Map<String, List> param = Collections.singletonMap("apps", appList);
		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new
				NamedParameterJdbcTemplate(getJdbcTemplate().getDataSource());
		flowNames = namedParameterJdbcTemplate.queryForList(
				GET_FLOW_NAMES_BY_APP, param, String.class);
	}
	else
	{
		flowNames = getJdbcTemplate().queryForList(GET_FLOW_NAMES, String.class);
	}

	return flowNames;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:21,代碼來源:AdvSearchDAO.java

示例13: intercept

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
public void intercept(final NamedParameterJdbcTemplate jdbcTemplate) throws Exception {
    JdbcTemplate innerJdbcTemplate = (JdbcTemplate) jdbcTemplate.getJdbcOperations();
    this.jdbcTemplate = innerJdbcTemplate;
    DataSource dataSource = (innerJdbcTemplate.getDataSource());

    Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(JdbcTemplate.class);
    Callback noOpCb = NoOp.INSTANCE;
    Callback[] callbacks = new Callback[]{noOpCb, this};
    enhancer.setCallbacks(callbacks);
    enhancer.setCallbackFilter(this);
    JdbcTemplate proxy = (JdbcTemplate) enhancer.create(new Class[]{DataSource.class}, new Object[]{dataSource});

    Field jdbcTemplateField = jdbcTemplate.getClass().getDeclaredField("classicJdbcTemplate");
    jdbcTemplateField.setAccessible(true);
    jdbcTemplateField.set(jdbcTemplate, proxy);
}
 
開發者ID:ChenAt,項目名稱:common-dao,代碼行數:18,代碼來源:QueryInterceptor.java

示例14: DaoSupport

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
@Autowired
public DaoSupport(NamedParameterJdbcTemplate jdbcTemplate,String basePackage) {
    selectSupport = new SelectSupport(jdbcTemplate);
    updateSupport = new UpdateSupport(jdbcTemplate);
    deleteSupport = new DeleteSupport(jdbcTemplate);
    insertSupport = new InsertSupport(jdbcTemplate);

    try {
        this.queryInterceptor = new QueryInterceptor(jdbcTemplate);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("hook jdbcTemplate query methid fail,", e);
    }
    this.basePackage = basePackage;
    if (StringUtil.isEmpty(basePackage)) {
        this.basePackage = "*";
    }
    List<Class<?>> entityClassList = new EntityScanner().scan(basePackage);
    for (Class<?> clazz : entityClassList) {
        getEntity(clazz);
    }
}
 
開發者ID:ChenAt,項目名稱:common-dao,代碼行數:23,代碼來源:DaoSupport.java

示例15: initDao

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; //導入依賴的package包/類
/**
 * Init dao.
 */
protected void initDao() throws Exception {
	this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getDataSource());

	this.updateQuery = "UPDATE " + this.tableName
	                   + " SET " + this.tableValueColumn + " = :config_value "
	                   + " WHERE " + this.tableKeyColumn + " = :config_key "
	                   + " AND " + this.tableEnvColumn + " = :config_env";

	this.listQuery = "SELECT "
	                 + this.tableEnvColumn + ", "
	                 + this.tableKeyColumn + ", "
	                 + this.tableValueColumn
	                 + " FROM " + this.tableName
	                 + " WHERE " + this.tableEnvColumn + " = :config_env"
	                 + " OR " + this.tableEnvColumn + " = :default_env_key";

	this.getQuery = "SELECT "
	                + this.tableEnvColumn + ", "
	                + this.tableKeyColumn + ", "
	                + this.tableValueColumn
	                + " FROM " + this.tableName
	                + " WHERE " + this.tableKeyColumn + " = :config_key"
	                + " AND " + this.tableEnvColumn + " = :config_env";

}
 
開發者ID:namics,項目名稱:spring-configuration-support,代碼行數:29,代碼來源:ConfigurationDaoImpl.java


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