Jdbi: Expose SqlObject dispatch machinery for public use

Created on 21 Aug 2016  路  3Comments  路  Source: jdbi/jdbi

I propose making the following SqlObject types public:

  • Handler
  • @SqlMethodAnnotation and HandlerFactory
  • @SqlMethodDecoratingAnnotation and HandlerDecorator

This will allow users and library authors to create their own SQL method handlers and decorators, which will in turn make caching feasible as a bolt-on option for users who want it, although there may be other use cases we haven't thought of.

We should also introduce a way of specifying order for when there are multiple decorators. My gut tells me that a static @Priority annotation is not the best approach, since users might want different ordering in different scenarios.

Most helpful comment

OK by me.

All 3 comments

For multiple decorators, one approach might be:

@interface DecoratorOrder {
  Class<? extends Annotation>[] value();
}

Thus, in a sql object:

@FooDecorator
@BarDecorator
@DecoratorOrder(BarDecorator.class, FooDecorator.class)
List<Thing> listAllTheThings();

If you don't specify an order, then decorator order is undefined.

OK by me.

Fixed in #458

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhardtke picture dhardtke  路  3Comments

rherrmann picture rherrmann  路  4Comments

nonameplum picture nonameplum  路  5Comments

Romqa picture Romqa  路  5Comments

electrum picture electrum  路  3Comments