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


Java ResultSetMapper类代码示例

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


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

示例1: mapperFor

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ResultSetMapper mapperFor(Class aClass, StatementContext statementContext) {
    ResultSetMapper mapper = cache.get(aClass);

    if (mapper == null) {
        Mapper<ResultSet, ?> resultSetMapper = mapperFactory.newInstance(aClass);
        mapper = toResultSetMapper(resultSetMapper);
        ResultSetMapper<?> cachedMapper = cache.putIfAbsent(aClass, mapper);
        if (cachedMapper != null) {
            mapper = cachedMapper;
        }
    }

    return mapper;
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:17,代码来源:SfmResultSetMapperFactory.java

示例2: get

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
private WebHook get(String project, String identifier) {
    try (Handle handle = dbi.open()) {
        WebHook first = handle.createQuery("SELECT code, image, active, parameters FROM webhook WHERE project = :project AND identifier = :identifier")
                .bind("project", project)
                .bind("identifier", identifier)
                .map(new ResultSetMapper<WebHook>() {
                    @Override
                    public WebHook map(int index, ResultSet r, StatementContext ctx)
                            throws SQLException {
                        return new WebHook(identifier, r.getString(1),
                                r.getString(2), r.getBoolean(3),
                                JsonHelper.read(r.getString(4), new TypeReference<Map<String, Parameter>>() {
                                }));
                    }
                }).first();
        if (first == null) {
            throw new RakamException(NOT_FOUND);
        }
        return first;
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:22,代码来源:WebHookHttpService.java

示例3: list

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@ApiOperation(value = "Get hook", authorizations = @Authorization(value = "master_key"))
@Path("/list")
@GET
public List<WebHook> list(@Named("project") RequestContext context) {
    try (Handle handle = dbi.open()) {
        return handle.createQuery("SELECT identifier, code, image, active, parameters FROM webhook WHERE project = :project")
                .bind("project", context.project)
                .map(new ResultSetMapper<WebHook>() {
                    @Override
                    public WebHook map(int index, ResultSet r, StatementContext ctx)
                            throws SQLException {
                        return new WebHook(r.getString(1), r.getString(2), r.getString(3), r.getBoolean(4), JsonHelper.read(r.getString(5), Map.class));
                    }
                }).list();
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:17,代码来源:WebHookHttpService.java

示例4: mapperFor

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Override
public ResultSetMapper mapperFor(Class type, StatementContext ctx) {
    return (index, r, _ctx) -> {
        Constructor ctor = type.getDeclaredConstructors()[0];
        int cnt = ctor.getParameterCount();

        List<String> args = Lists.newArrayList();
        for (int i = 1; i <= cnt; i++) {
            args.add(r.getString(i));
        }

        try {
            return ctor.newInstance(args.toArray());
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    };
}
 
开发者ID:brianm,项目名称:muckery,代码行数:19,代码来源:ProjectionMappingExampleTest.java

示例5: configure

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Override
public void configure() {
  Multibinder<ResultSetMapper<?>> resultSetMappers = Multibinder.newSetBinder(binder(), new TypeLiteral<ResultSetMapper<?>>() {});

  resultSetMappers.addBinding().to(SingularityMappers.SingularityBytesMapper.class).in(Scopes.SINGLETON);
  resultSetMappers.addBinding().to(SingularityMappers.SingularityRequestIdMapper.class).in(Scopes.SINGLETON);
  resultSetMappers.addBinding().to(SingularityMappers.SingularityRequestHistoryMapper.class).in(Scopes.SINGLETON);
  resultSetMappers.addBinding().to(SingularityMappers.SingularityTaskIdHistoryMapper.class).in(Scopes.SINGLETON);
  resultSetMappers.addBinding().to(SingularityMappers.SingularityDeployHistoryLiteMapper.class).in(Scopes.SINGLETON);
  resultSetMappers.addBinding().to(SingularityMappers.SingularityRequestIdCountMapper.class).in(Scopes.SINGLETON);
  resultSetMappers.addBinding().to(SingularityMappers.DateMapper.class).in(Scopes.SINGLETON);

  bind(TaskHistoryHelper.class).in(Scopes.SINGLETON);
  bind(RequestHistoryHelper.class).in(Scopes.SINGLETON);
  bind(DeployHistoryHelper.class).in(Scopes.SINGLETON);
  bind(DeployTaskHistoryHelper.class).in(Scopes.SINGLETON);
  bind(SingularityRequestHistoryPersister.class).in(Scopes.SINGLETON);
  bind(SingularityDeployHistoryPersister.class).in(Scopes.SINGLETON);
  bind(SingularityTaskHistoryPersister.class).in(Scopes.SINGLETON);

  if (configuration.isPresent()) {
    bind(DBI.class).toProvider(DBIProvider.class).in(Scopes.SINGLETON);
    bind(HistoryJDBI.class).toProvider(HistoryJDBIProvider.class).in(Scopes.SINGLETON);
    bind(HistoryManager.class).to(JDBIHistoryManager.class).in(Scopes.SINGLETON);

    bindMethodInterceptorForStringTemplateClassLoaderWorkaround();
  } else {
    bind(HistoryManager.class).to(NoopHistoryManager.class).in(Scopes.SINGLETON);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:31,代码来源:SingularityHistoryModule.java

示例6: get

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Override
public DBI get() {
  try {
    DBI dbi = dbiFactory.build(environment, dataSourceFactory, "db");
    for (ResultSetMapper<?> resultSetMapper : resultSetMappers) {
      dbi.registerMapper(resultSetMapper);
    }

    return dbi;
  } catch (ClassNotFoundException e) {
    throw new ProvisionException("while instantiating DBI", e);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:14,代码来源:SingularityHistoryModule.java

示例7: SqlMap

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
public SqlMap(String tableName, String keyColumnName, String valueColumnName, DataSource dataSource,
              VertexiumSerializer serializer) {
    this.tableName = tableName;
    this.keyColumnName = keyColumnName;
    this.valueColumnName = valueColumnName;
    this.dbi = new DBI(dataSource);
    this.serializer = serializer;
    this.entrySetMapper = new ResultSetMapper<MapEntry<byte[]>>() {
        public MapEntry<byte[]> map(int index, ResultSet rs, StatementContext ctx) throws SQLException {
            String key = rs.getString(SqlMap.this.keyColumnName);
            byte[] value = rs.getBytes(SqlMap.this.valueColumnName);
            return new MapEntry<>(key, value);
        }
    };
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:16,代码来源:SqlMap.java

示例8: DbCollection

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
DbCollection(String tableName, Handle handle, SelectionMap selectionMap, AbstractSelectionMapFactory<T> selectionMapFactory, ResultSetMapper<T> fieldMapper) {
    this.tableName = tableName;
    this.handle = handle;
    this.selectionMap = selectionMap;
    this.selectionMapFactory = selectionMapFactory;
    this.fieldMapper = fieldMapper;
}
 
开发者ID:reines,项目名称:db-table,代码行数:8,代码来源:DbCollection.java

示例9: toResultSetMapper

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
private <T> ResultSetMapper<T> toResultSetMapper(Mapper<ResultSet, T> resultSetMapper) {
    ResultSetMapper mapper;
    if (resultSetMapper instanceof DynamicJdbcMapper) {
        mapper = new DynamicSfmResultSetMapper<T>((DynamicJdbcMapper<T>) resultSetMapper);
    } else {
        mapper = new DefaultSfmResultSetMapper<T>(resultSetMapper);
    }
    return mapper;
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:10,代码来源:SfmResultSetMapperFactory.java

示例10: getAll

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
public Map<String, Object> getAll(Handle handle, @Named("user_id") UIPermissionParameterProvider.Project project) {
    return handle.createQuery("SELECT name, value FROM ui_user_defaults WHERE user_id = :user AND project_id = :project")
            .bind("project", project.project)
            .bind("user", project.userId)
            .map((ResultSetMapper<Map.Entry<String, Object>>) (index, r, ctx) ->
                    new AbstractMap.SimpleImmutableEntry<>(r.getString(1), JsonHelper.read(r.getString(2), Object.class)))
            .list().stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:9,代码来源:UserDefaultService.java

示例11: get

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Override
public DBI get() {
  try {
    DBI dbi = dbiFactory.build(environment, dataSourceFactory, "db");
    for (ResultSetMapper<?> resultSetMapper : resultSetMappers) {
      dbi.registerMapper(resultSetMapper);
    }

    return dbi;
  } catch (Exception e) {
    throw new ProvisionException("while instantiating DBI", e);
  }
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:14,代码来源:SingularityHistoryModule.java

示例12: setMappers

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Inject(optional = true)
void setMappers(Set<ResultSetMapper<?>> resultSetMappers) {
  checkNotNull(resultSetMappers, "resultSetMappers is null");
  this.resultSetMappers = ImmutableSet.copyOf(resultSetMappers);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:6,代码来源:SingularityHistoryModule.java

示例13: mapperFor

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Override
public ResultSetMapper mapperFor(Class type, StatementContext ctx)
{
    return new UuidMapper();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:6,代码来源:UuidUtil.java

示例14: DbSet

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
DbSet(String tableName, Handle handle, SelectionMap selectionMap, AbstractSelectionMapFactory<T> selectionMapFactory, ResultSetMapper<T> fieldMapper) {
    super (tableName, handle, selectionMap, selectionMapFactory, fieldMapper);
}
 
开发者ID:reines,项目名称:db-table,代码行数:4,代码来源:DbSet.java

示例15: mapperFor

import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
public ResultSetMapper mapperFor(Class type, StatementContext ctx) {
  return MAPPERS.get(type);
}
 
开发者ID:robfletcher,项目名称:jdbi-time,代码行数:4,代码来源:TimeTypesMapperFactory.java


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