I understand. I'm not concerned about performance; that would make a very minor difference. But all my keys are UUIDs and right now my DAO interfaces only accept strings:TemplateDto selectSingle(@Bind("tenantId") String tenantId, @Bind("templateId") String templateId);That means I have to convert the values to strings when using these APIs, which is a bit cumbersome and error-prone:TemplateDto templateDto = templatesDao.selectSingle(tenantId.get().toString(), templateId.get().toString());Is there a way to write a custom mapper on JDBI so I could write the interface method accepting UUIDs, but have it convert them to string when passing the parameter to the SqlQuery? Something like:TemplateDto selectSingle(@Bind("tenantId") UUID tenantId, @Bind("templateId") UUID templateId);So the API would base based explicitly on the data types of the DTOs.But again, without necessarily passing them along to the database as UUIDs, just converting them to string before binding the parameters. I don't know JDBI enough to understand if that's possible or how difficult it would be.
JDBI only exposes explicite type based bindings for the types which JDBC exposes them for. JDBC does not expose a UUID type for binding, os it is defaulting to setting it as an Object. Unfortunately, JDBC offers not explicit UUID binding mechanism, so going through String is probably the most portable way :-(
If you want to bind it as a UUID in Java and have it converted to a String internally, there are two paths. The first, if you always want to bind UUIDs as Strings is to use an ArgumentFactory, seehttps://github.com/brianm/jdbi/blob/master/src/test/java/org/skife/jdbi/v2/sqlobject/TestRegisterArgumentFactory.java for an example.
The second is, if you want to do it only in specific cases, to create a custom Binder, such as withhttp://jdbi.org/sql_object_api_argument_binding/
-Brian