Jdbi: 公开 SqlObject 调度机制供公众使用

创建于 2016-08-21  ·  3评论  ·  资料来源: jdbi/jdbi

我建议公开以下 SqlObject 类型:

  • Handler
  • @SqlMethodAnnotationHandlerFactory
  • @SqlMethodDecoratingAnnotationHandlerDecorator

这将允许用户和库作者创建他们自己的 SQL 方法处理程序和装饰器,这反过来将使缓存成为需要它的用户的附加选项,尽管可能还有我们没有想到的其他用例。

当有多个装饰器时,我们还应该引入一种指定顺序的方法。 我的直觉告诉我,静态的@Priority注释不是最好的方法,因为用户可能希望在不同的场景中进行不同的排序。

最有用的评论

由我确定。

所有3条评论

对于多个装饰器,一种方法可能是:

<strong i="6">@interface</strong> DecoratorOrder {
  Class<? extends Annotation>[] value();
}

因此,在一个 sql 对象中:

<strong i="10">@FooDecorator</strong>
<strong i="11">@BarDecorator</strong>
@DecoratorOrder(BarDecorator.class, FooDecorator.class)
List<Thing> listAllTheThings();

如果不指定顺序,则装饰器顺序未定义。

由我确定。

已修复 #458

此页面是否有帮助?
0 / 5 - 0 等级