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


Java StringColumnMapper类代码示例

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


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

示例1: fetchIdsByPropertyValueFullTableScan

import org.skife.jdbi.v2.util.StringColumnMapper; //导入依赖的package包/类
protected Set<String> fetchIdsByPropertyValueFullTableScan(final String collectionPath, final String property, final String value) {
    final String pathRegex = collectionPath + "/:[^/]+/" + property;

    final AtomicReference<Set<String>> ret = new AtomicReference<>();
    withTransaction(dbi -> {
        final String query;
        if (databaseKind == DatabaseKind.PostgreSQL) {
            query = "SELECT regexp_replace(path, '(/.+/:[^/]+).*', '\\1') from jsondb where path ~ ? and value = ?";
        } else if (databaseKind == DatabaseKind.H2) {
            query = "SELECT regexp_replace(path, '(/.+/:[^/]+).*', '$1') from jsondb where path regexp ? and value = ?";
        } else {
            throw new UnsupportedOperationException(
                "Don't know how to use regex in a query with database: " + databaseKind);
        }

        final List<String> paths = dbi.createQuery(query).bind(0, pathRegex).bind(1, value)
            .map(StringColumnMapper.INSTANCE).list();

        ret.set(new HashSet<>(paths));
    });

    return ret.get();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:24,代码来源:SqlJsonDB.java

示例2: fetchIdsByPropertyValue

import org.skife.jdbi.v2.util.StringColumnMapper; //导入依赖的package包/类
@Override
public Set<String> fetchIdsByPropertyValue(final String collectionPath, final String property, final String value) {
    final String pathRegex = collectionPath + "/:[^/]+/" + property;

    final AtomicReference<Set<String>> ret = new AtomicReference<>();
    withTransaction(dbi -> {
        final String query;
        if (databaseKind == DatabaseKind.PostgreSQL) {
            query = "SELECT regexp_replace(path, '(/.+/:[^/]+).*', '\\1') from jsondb where path ~ ? and value = ?";
        } else if (databaseKind == DatabaseKind.H2) {
            query = "SELECT regexp_replace(path, '(/.+/:[^/]+).*', '$1') from jsondb where path regexp ? and value = ?";
        } else {
            throw new UnsupportedOperationException(
                "Don't know how to use regex in a query with database: " + databaseKind);
        }

        final List<String> paths = dbi.createQuery(query).bind(0, pathRegex).bind(1, value)
            .map(StringColumnMapper.INSTANCE).list();

        ret.set(new HashSet<>(paths));
    });

    return ret.get();
}
 
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:25,代码来源:SqlJsonDB.java

示例3: fetchIdsByPropertyValue

import org.skife.jdbi.v2.util.StringColumnMapper; //导入依赖的package包/类
@Override
public Set<String> fetchIdsByPropertyValue(final String collectionPath, final String property, final String value) {

    String path = prefix(trimSuffix(collectionPath, "/"), "/");

    String idx = path+"/"+property;
    if( !indexes.contains(idx) ) {
        String message = "Index not defined for:  collectionPath: " + path + ", property: " + property;
        LOG.warn("fetchIdsByPropertyValue not optimzed !!!: {}", message);
        return fetchIdsByPropertyValueFullTableScan(collectionPath, property, value);
    } else {
        final AtomicReference<Set<String>> ret = new AtomicReference<>();
        withTransaction(dbi -> {
            final String query = "SELECT path FROM jsondb WHERE idx = ? AND value = ?";
            final List<String> paths = dbi.createQuery(query)
                .bind(0, idx)
                .bind(1, value)
                .map(StringColumnMapper.INSTANCE).list();

            String suffix = "/" + property + "/";
            ret.set(paths.stream()
                .map(x -> trimSuffix(x, suffix))
                .collect(Collectors.toCollection(HashSet::new)));
        });
        return ret.get();
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:28,代码来源:SqlJsonDB.java


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