本文整理汇总了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;
}
示例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;
}
}
示例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();
}
}
示例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);
}
};
}
示例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);
}
}
示例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);
}
}
示例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);
}
};
}
示例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;
}
示例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;
}
示例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()));
}
示例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);
}
}
示例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);
}
示例13: mapperFor
import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
@Override
public ResultSetMapper mapperFor(Class type, StatementContext ctx)
{
return new UuidMapper();
}
示例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);
}
示例15: mapperFor
import org.skife.jdbi.v2.tweak.ResultSetMapper; //导入依赖的package包/类
public ResultSetMapper mapperFor(Class type, StatementContext ctx) {
return MAPPERS.get(type);
}