use of org.jdbi.v3.postgres.PostgresTypes in project Hangar by HangarMC.
the class JDBIConfig method jdbi.
@Bean
public Jdbi jdbi(DataSource dataSource, List<JdbiPlugin> jdbiPlugins, List<RowMapper<?>> rowMappers, List<RowMapperFactory> rowMapperFactories, List<ColumnMapper<?>> columnMappers) {
SqlLogger myLogger = new SqlLogger() {
@Override
public void logException(StatementContext context, SQLException ex) {
Logger.getLogger("sql").info("sql: " + context.getRenderedSql());
}
@Override
public void logAfterExecution(StatementContext context) {
Logger.getLogger("sql").info("sql ae: " + context.getRenderedSql());
}
};
TransactionAwareDataSourceProxy dataSourceProxy = new TransactionAwareDataSourceProxy(dataSource);
Jdbi jdbi = Jdbi.create(dataSourceProxy);
// jdbi.setSqlLogger(myLogger); // for debugging sql statements
PostgresTypes config = jdbi.getConfig(PostgresTypes.class);
jdbiPlugins.forEach(jdbi::installPlugin);
rowMappers.forEach(jdbi::registerRowMapper);
rowMapperFactories.forEach(jdbi::registerRowMapper);
columnMappers.forEach(jdbi::registerColumnMapper);
config.registerCustomType(PGLoggedAction.class, "logged_action_type");
config.registerCustomType(RoleCategory.class, "role_category");
config.registerCustomType(JobState.class, "job_state");
config.registerCustomType(JSONB.class, "jsonb");
return jdbi;
}
Aggregations