Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Dropwizard JDBI to JDBI 3

How do you upgrade dropwizard jdbi 2.78 to jdbi version 3 since I want to make use of the joins functionality included in it.

like image 895
user2987773 Avatar asked Dec 18 '22 06:12

user2987773


1 Answers

Project member here.

We'll be publishing a more complete migration guide prior to v3 final release. In the meantime, one of our users just submitted a decent list of changes as a starting point:

(See https://github.com/jdbi/jdbi/issues/715)

  • Renamed classes (so not quite as simple as deleting imports and letting the IDE fix it):

    • DBI -> Jdbi
    • IDBI -> Jdbi
    • DBIException -> JdbiException
  • The constructors for Jdbi have been replaced with a create() factory method.

  • ResultSetMapper is replaced with RowMapper and the map method no longer has the row index. A class named ResultSetMapper exists in Jdbi 3, but it serves a different purpose. @Mapper is replaced with @UseRowMapper. registerMapper() on Jdbi is replaced with registerRowMapper().

  • @BindIn is replaced with @BindList and no longer requires StringTemplate.

  • With the default Jdbi templating, angle brackets are not quoted, which means that IntelliJ understands the syntax after you configure the Parameter Pattern under Tools -> Database -> User Patterns.

  • Query no longer has a default type of Map and thus list() cannot be called on it directly. Call mapToMap() before calling list().

  • TransactionStatus no longer exists.

  • TransactionConsumer.useTransaction() only takes a Handle now, so the TransactionStatus argument needs to be removed when using this with the useTransaction() methods on Jdbi or Handle.

  • TransactionCallback.inTransaction() only takes a Handle now, so the TransactionStatus argument needs to be removed when using this with the inTransaction() methods on Jdbi or Handle.

  • CallbackFailedException no longer exists. The various functional interfaces such as HandleConsumer, HandleCallback, TransactionalConsumer, and TransactionalCallback, can now throw any exception type (but restricted using generics to avoid needless checked exception handling).

  • SQL Object support is no longer available by default. It must be registered every created Jdbi instance.

like image 182
qualidafial Avatar answered Mar 02 '23 22:03

qualidafial