org.jdbi.v3.core.mapper.RowMapper Java Examples
The following examples show how to use
org.jdbi.v3.core.mapper.RowMapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SfmRowMapperFactory.java From SimpleFlatMapper with MIT License | 6 votes |
@Override public Optional<RowMapper<?>> build(Type type, ConfigRegistry configRegistry) { if (acceptsPredicate.test(type, configRegistry)) { RowMapper<?> rowMapper = cache.get(type); if (rowMapper == null) { ContextualSourceMapper<ResultSet, ?> resultSetMapper = mapperFactory.newInstance(type); rowMapper = toRowMapper(resultSetMapper); RowMapper<?> cachedMapper = cache.putIfAbsent(type, rowMapper); if (cachedMapper != null) { rowMapper = cachedMapper; } } return Optional.of(rowMapper); } return Optional.empty(); }
Example #2
Source File: PlayerApiKeyLookupRecord.java From triplea with GNU General Public License v3.0 | 6 votes |
/** Returns a JDBI row mapper used to convert a ResultSet into an instance of this bean object. */ public static RowMapper<PlayerApiKeyLookupRecord> buildResultMapper() { return (rs, ctx) -> { final var apiKeyLookupRecord = PlayerApiKeyLookupRecord.builder() .apiKeyId(rs.getInt("api_key_id")) .userId(rs.getInt("user_id")) .playerChatId(Preconditions.checkNotNull(rs.getString("player_chat_id"))) .role(Preconditions.checkNotNull(rs.getString("user_role"))) .username(rs.getString("username")) .build(); verifyState(apiKeyLookupRecord); return apiKeyLookupRecord; }; }
Example #3
Source File: PlayerAliasRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<PlayerAliasRecord> buildResultMapper() { return (rs, ctx) -> PlayerAliasRecord.builder() .username(rs.getString("name")) .ip(rs.getString("ip")) .systemId(rs.getString("systemId")) .date(TimestampMapper.map(rs, "accessTime")) .build(); }
Example #4
Source File: SingularityDbModule.java From Singularity with Apache License 2.0 | 5 votes |
@Inject(optional = true) void setMappers( Set<RowMapper<?>> rowMappers, Set<ColumnMapper<?>> columnMappers, @Singularity ObjectMapper objectMapper ) { checkNotNull(rowMappers, "resultSetMappers is null"); this.rowMappers = ImmutableSet.copyOf(rowMappers); this.columnMappers = ImmutableSet.copyOf(columnMappers); this.objectMapper = objectMapper; }
Example #5
Source File: RosettaRowMapperFactory.java From Rosetta with Apache License 2.0 | 5 votes |
@Override public Optional<RowMapper<?>> build(Type type, ConfigRegistry config) { if (accepts(type, config)) { return Optional.of((rs, ctx) -> { ObjectMapper objectMapper = ctx.getConfig(RosettaObjectMapper.class).getObjectMapper(); String tableName = SqlTableNameExtractor.extractTableName(ctx.getParsedSql().getSql()); final RosettaMapper mapper = new RosettaMapper(type, objectMapper, tableName); return mapper.mapRow(rs); }); } else { return Optional.empty(); } }
Example #6
Source File: SfmRowMapperFactory.java From SimpleFlatMapper with MIT License | 5 votes |
private <T> RowMapper<T> toRowMapper(ContextualSourceMapper<ResultSet, T> resultSetMapper) { RowMapper<T> mapper; if (resultSetMapper instanceof DynamicJdbcMapper) { mapper = new DynamicRowMapper<T>((DynamicJdbcMapper<T>) resultSetMapper); } else { mapper = new StaticRowMapper<T>(resultSetMapper); } return mapper; }
Example #7
Source File: AccessLogRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<AccessLogRecord> buildResultMapper() { return (rs, ctx) -> AccessLogRecord.builder() .accessTime(TimestampMapper.map(rs, "access_time")) .username(rs.getString("username")) .ip(rs.getString("ip")) .systemId(rs.getString("system_id")) .registered(rs.getBoolean("registered")) .build(); }
Example #8
Source File: UserBanRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<UserBanRecord> buildResultMapper() { return (rs, ctx) -> UserBanRecord.builder() .publicBanId(rs.getString("public_id")) .username(rs.getString("username")) .systemId(rs.getString("system_id")) .ip(rs.getString("ip")) .dateCreated(TimestampMapper.map(rs, "date_created")) .banExpiry(TimestampMapper.map(rs, "ban_expiry")) .build(); }
Example #9
Source File: BanLookupRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<BanLookupRecord> buildResultMapper() { return (rs, ctx) -> BanLookupRecord.builder() .publicBanId(rs.getString("public_id")) .banExpiry(TimestampMapper.map(rs, "ban_expiry")) .build(); }
Example #10
Source File: UserRoleLookup.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<UserRoleLookup> buildResultMapper() { return (rs, ctx) -> { final UserRoleLookup roleLookup = UserRoleLookup.builder() .userId(rs.getInt("id")) .userRoleId(rs.getInt("user_role_id")) .build(); Postconditions.assertState(roleLookup.userId != 0); Postconditions.assertState(roleLookup.userRoleId != 0); return roleLookup; }; }
Example #11
Source File: PlayerIdentifiersByApiKeyLookup.java From triplea with GNU General Public License v3.0 | 5 votes |
public static RowMapper<PlayerIdentifiersByApiKeyLookup> buildResultMapper() { return (rs, ctx) -> PlayerIdentifiersByApiKeyLookup.builder() .userName(UserName.of(rs.getString("username"))) .systemId(SystemId.of(rs.getString("system_id"))) .ip(rs.getString("ip")) .build(); }
Example #12
Source File: UsernameBanRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<UsernameBanRecord> buildResultMapper() { return (rs, ctx) -> UsernameBanRecord.builder() .username(rs.getString("username")) .dateCreated(TimestampMapper.map(rs, "date_created")) .build(); }
Example #13
Source File: ModeratorUserDaoData.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<ModeratorUserDaoData> buildResultMapper() { return (rs, ctx) -> ModeratorUserDaoData.builder() .username(rs.getString("username")) .lastLogin(TimestampMapper.map(rs, "access_time")) .build(); }
Example #14
Source File: ChatHistoryRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<ChatHistoryRecord> buildResultMapper() { return (rs, ctx) -> ChatHistoryRecord.builder() .date(TimestampMapper.map(rs, "date")) .username(rs.getString("username")) .message(rs.getString("message")) .build(); }
Example #15
Source File: ModeratorAuditHistoryRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
/** Returns a JDBI row mapper used to convert results into an instance of this bean object. */ public static RowMapper<ModeratorAuditHistoryRecord> buildResultMapper() { return (rs, ctx) -> ModeratorAuditHistoryRecord.builder() .dateCreated(TimestampMapper.map(rs, "date_created")) .username(rs.getString("username")) .actionName(rs.getString("action_name")) .actionTarget(rs.getString("action_target")) .build(); }
Example #16
Source File: PlayerBanRecord.java From triplea with GNU General Public License v3.0 | 5 votes |
public static RowMapper<PlayerBanRecord> buildResultMapper() { return (rs, ctx) -> PlayerBanRecord.builder() .username(rs.getString("name")) .ip(rs.getString("ip")) .systemId(rs.getString("systemId")) .banStart(TimestampMapper.map(rs, "banStart")) .banEnd(TimestampMapper.map(rs, "banEnd")) .build(); }
Example #17
Source File: JdbcStorage.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see io.apicurio.hub.core.storage.IStorage#lookupEditingSessionUuid(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public long lookupEditingSessionUuid(String uuid, String designId, String userId, String hash) throws StorageException { logger.debug("Looking up an editing session UUID: {}", uuid); long now = System.currentTimeMillis(); try { return this.jdbi.withHandle( handle -> { String statement = sqlStatements.selectEditingSessionUuid(); Long contentVersion = handle.createQuery(statement) .bind(0, uuid) .bind(1, Long.valueOf(designId)) .bind(2, hash) .bind(3, now) .map(new RowMapper<Long>() { @Override public Long map(ResultSet rs, StatementContext ctx) throws SQLException { return rs.getLong("version"); } }) .one(); return contentVersion; }); } catch (Exception e) { throw new StorageException("Error getting Editing Session UUID.", e); } }
Example #18
Source File: PlayerHistoryRecord.java From triplea with GNU General Public License v3.0 | 4 votes |
public static RowMapper<PlayerHistoryRecord> buildResultMapper() { return (rs, ctx) -> PlayerHistoryRecord.builder() .registrationDate(TimestampMapper.map(rs, "date_registered").toEpochMilli()) .build(); }
Example #19
Source File: DynamicRowMapper.java From SimpleFlatMapper with MIT License | 4 votes |
@Override public RowMapper<T> specialize(ResultSet rs, StatementContext ctx) throws SQLException { return new StaticRowMapper<T>(dynamicMapper.getMapper(rs.getMetaData())); }
Example #20
Source File: SingularityHistoryModule.java From Singularity with Apache License 2.0 | 4 votes |
@Override public void configure() { Multibinder<RowMapper<?>> rowMappers = Multibinder.newSetBinder( binder(), new TypeLiteral<RowMapper<?>>() {} ); rowMappers .addBinding() .to(SingularityMappers.SingularityRequestHistoryMapper.class) .in(Scopes.SINGLETON); rowMappers .addBinding() .to(SingularityMappers.SingularityTaskIdHistoryMapper.class) .in(Scopes.SINGLETON); rowMappers .addBinding() .to(SingularityMappers.SingularityDeployHistoryLiteMapper.class) .in(Scopes.SINGLETON); rowMappers .addBinding() .to(SingularityMappers.SingularityRequestIdCountMapper.class) .in(Scopes.SINGLETON); rowMappers .addBinding() .to(SingularityMappers.SingularityTaskUsageMapper.class) .in(Scopes.SINGLETON); rowMappers .addBinding() .to(SingularityMappers.SingularityRequestWithTimeMapper.class) .in(Scopes.SINGLETON); Multibinder<ColumnMapper<?>> columnMappers = Multibinder.newSetBinder( binder(), new TypeLiteral<ColumnMapper<?>>() {} ); columnMappers .addBinding() .to(SingularityMappers.SingularityBytesMapper.class) .in(Scopes.SINGLETON); columnMappers.addBinding().to(SingularityIdMapper.class).in(Scopes.SINGLETON); columnMappers.addBinding().to(SingularityJsonStringMapper.class).in(Scopes.SINGLETON); columnMappers .addBinding() .to(SingularityMappers.DateMapper.class) .in(Scopes.SINGLETON); columnMappers .addBinding() .to(SingularityMappers.SingularityTimestampMapper.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); }