简体   繁体   中英

Upgrading Dropwizard JDBI to JDBI 3

如何将dropwizard jdbi 2.78升级到jdbi版本3,因为我想利用其中包含的连接功能。

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.

请参阅Dropwizard用户手册中的Dropwizard JDBI3和Jdbi 3开发人员指南中从v2升级到v3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM