Вот одна из таких тем:
[img]https://i.sstatic .net/M6ojiGBp.png[/img]
Метод, выполняющий DSL.using, выглядит следующим образом:
Код: Выделить всё
public void myMethod(final Instant now) {
final int count = using(configuration)
.update(MY_TABLE)
.set(MY_TABLE.ACTIVE, true)
.where(MY_TABLE.PAUSED_UNTIL.isNotNull())
.and(MY_TABLE.ACTIVE.isFalse())
.execute();
if (count > 0) {
...
}
}
Код: Выделить всё
DataSource dataSource = DataSourceFactory.provide()
Configuration configuration = new DefaultConfiguration()
.derive(dataSource)
.derive(SQLDialect.POSTGRES)
.derive(EnumFixingExecuteListener::new);
Код: Выделить всё
public HikariDataSource provide() {
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
config.addDataSourceProperty("serverName", postgresConfig.host);
config.setMaximumPoolSize(6);
config.addDataSourceProperty("databaseName", postgresConfig.database);
config.addDataSourceProperty("user", postgresConfig.username);
config.addDataSourceProperty("password", postgresConfig.password);
HikariDataSource dataSource = new HikariDataSource(config);
log.trace("Providing dataSource {}", dataSource);
return dataSource;
}
Используемые версии:
- jOOQ 3.16.23 (Дата сборки: 2023-12-20T14:13:48Z)
- PostgreSQL 14.10
Подробнее здесь: https://stackoverflow.com/questions/788 ... -dsl-using