简体   繁体   English

将Dropwizard JDBI升级到JDBI 3

[英]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. 我们将在v3最终版本发布之前发布更完整的迁移指南。 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 ) (见https://github.com/jdbi/jdbi/issues/715

  • Renamed classes (so not quite as simple as deleting imports and letting the IDE fix it): 重命名类(所以不像删除导入那样简单,让IDE修复它):

    • DBI -> Jdbi DBI - > Jdbi
    • IDBI -> Jdbi IDBI - > Jdbi
    • DBIException -> JdbiException DBIException - > JdbiException
  • The constructors for Jdbi have been replaced with a create() factory method. Jdbi的构造函数已被create()工厂方法替换。

  • ResultSetMapper is replaced with RowMapper and the map method no longer has the row index. ResultSetMapper替换为RowMapper,map方法不再具有行索引。 A class named ResultSetMapper exists in Jdbi 3, but it serves a different purpose. Jdbi 3中存在一个名为ResultSetMapper的类,但它有不同的用途。 @Mapper is replaced with @UseRowMapper. @Mapper替换为@UseRowMapper。 registerMapper() on Jdbi is replaced with registerRowMapper(). Jdbi上的registerMapper()被registerRowMapper()取代。

  • @BindIn is replaced with @BindList and no longer requires StringTemplate. @BindIn替换为@BindList,不再需要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. 使用默认的Jdbi模板,不引用尖括号,这意味着在工具 - >数据库 - >用户模式下配置参数模式后,IntelliJ可以理解语法。

  • Query no longer has a default type of Map and thus list() cannot be called on it directly. 查询不再具有默认类型的Map,因此无法直接在其上调用list()。 Call mapToMap() before calling list(). 在调用list()之前调用mapToMap()。

  • TransactionStatus no longer exists. TransactionStatus不再存在。

  • 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. TransactionConsumer.useTransaction()现在只接受Handle,因此当在Jdbi或Handle上使用useTransaction()方法时,需要删除TransactionStatus参数。

  • 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. TransactionCallback.inTransaction()现在只接受一个Handle,因此当在Jdbi或Handle上使用onTransaction()方法时,需要删除TransactionStatus参数。

  • CallbackFailedException no longer exists. CallbackFailedException不再存在。 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). 各种功能接口(如HandleConsumer,HandleCallback,TransactionalConsumer和TransactionalCallback)现在可以抛出任何异常类型(但使用泛型来限制,以避免不必要的已检查异常处理)。

  • SQL Object support is no longer available by default. 默认情况下不再提供SQL对象支持。 It must be registered every created Jdbi instance. 必须在每个创建的Jdbi实例中注册它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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