Skip to content

4.0.0

Compare
Choose a tag to compare
@jklingsporn jklingsporn released this 23 Oct 14:28
· 242 commits to master since this release

Fast, faster, reactive

  • Starting from version 4.x, vertx-jooq adds support for this winning, high performance postgres driver.
  • Finally added support for DAO#insertReturning for the async postgres driver.
  • A new UnifiedQueryExecutor interface that allows the execution of arbitrary jOOQ-SQL against an API with the
    same return value for all drivers! Currently there are three interfaces you can use: ClassicQueryExecutor,
    CompletableFutureQueryExecutor and RXQueryExecutor. The following is possible now:
//first, you decide to use the classic API using JDBC
ClassicQueryExecutor queryExecutor = new JDBCClassicGenericQueryExecutor(configuration,vertx);
Future<QueryResult> queryResult = queryExecutor.query(dslContext ->
				dslContext
				.selectFrom(Tables.SOMETHING)
				.where(Tables.SOMETHING.SOMEID.eq(something.getSomeid()))
);
//fetching values using new QueryResult-API
queryResult.map(res -> {
	Integer someId = res.get(Tables.SOMETHING.SOMEID);
	return someId;
});
...
//now some time in the future you decide to use the reactive driver instead
ClassicQueryExecutor queryExecutor = new ReactiveClassicGenericQueryExecutor(configuration,pgClient);
//the return value for the query didn't change!
Future<QueryResult> queryResult = queryExecutor.query(dslContext ->
				dslContext
				.selectFrom(Tables.SOMETHING)
				.where(Tables.SOMETHING.SOMEID.eq(something.getSomeid()))
);
queryResult.map(res -> {
	Integer someId = res.get(Tables.SOMETHING.SOMEID);
	//hooray same API
	return someId;
});
  • In addition you can now obtain the QueryExecutor from every DAO by calling DAO.queryExecutor().
  • Move away from GeneratorStrategies to generate DAOs: it was a misconception to use GeneratorStrategies to distinguish
    between the APIs, drivers and injection-support. Instead, there is now a Builder-API to create the VertxGenerator of your choice.
    This comes in handy if you configure your jOOQ code generator programmatically. Example:
VertxGenerator vertxGenerator = VertxGeneratorBuilder
	.init()
	.withClassicAPI()
	.withAsyncDriver()
	.withGuice(true)
	.build();
  • Breaking changes:
    • DAOs are no longer aware of org.jooq.Configuration, instead it is now located in the QueryExecutor.
    • QueryExecutor API changed in a way, that all methods no longer accept instances of org.jooq.Query but Function<DSLContext, ? extends ResultQuery<R>>.
      It is no longer necessary to keep a Configuration object in order to execute random jOOQ SQL.
    • JDBCQueryExecutor.execute was renamed to JDBCQueryExecutor.executeAny.
    • Upgrade from 3.x: first, change the generator- and strategy name in your code generator configuration.
      Use the names as described in the module's documentation of the API and driver of your choice (e.g. vertx-jooq-classic-async).
      If you've used own GeneratorStrategies all have to extend now from VertxGeneratorStrategy.
      Then, update the dependencies to the code-generator and generate the code. Now you should update the vertx-jooq-YOUR_API-YOUR_DRIVER
      dependency. In case you've been using QueryExecutors you'll have to change the method calls to it as described above.

Related issues:
https://github.com/jklingsporn/vertx-jooq/milestone/11?closed=1