Binding Arguments to non-standard types

Skip to first unread message

Richard Stanford

Jul 15, 2021, 6:47:56 PM7/15/21
to jDBI
I'm using v3, and looking for a way to bind a custom argument more closely.  Specifically, a mapping to a few of the geospatial types in MariaDB.  Its simple enough to use something like ST_GeomFromText(), but what I'd prefer to do (and do everywhere else in the codebase with complex bindings) is to be able to do that automatically so that its a "pain once" situation.

I've noticed that some other frameworks have a way to modify the generated SQL based on the datatype of the bound variable. My goal would be that the end user can just call .bind("polygon", myPolygon) and have JDBI key off the class of the myPolygon object and generate the appropriate SQL.  I'm more than fine with only having this happen when an object of a specific class is passed in as a bind variable.

We use several instances of using AbstractArgumentFactory and I notice that the PreparedStatement and StatementContext are available to the call but unused in all of the examples.  Any chance that we can write intercept code here?  Otherwise these will be the only instances where our developers have to think about the type of the object they're binding in an update statement, which is unfortunately messy.

Any ideas?
Reply all
Reply to author
0 new messages