@SqlUpdate("update samples set file = :file where flag = true")
int updateFile(@Bind("file") InputStream file);
@SqlUpdate("update samples set file = :file where flag = true")
fun updateFile(@Bind("file") file: InputStream?): Int
It's not possible with JDBI3 ...
org.jdbi.v3.core.statement.UnableToCreateStatementException: No argument factory registered for type ...
I get an error like
When I searched for error messages on GitHub, ↓ is suspicious
return new UnableToCreateStatementException("No argument factory registered for '" + value + "' of qualified type " + qualifiedType, ctx);
https://github.com/jdbi/jdbi/blob/3c93a316d5cbf9507e668b62414daae759641e93/core/src/main/java/org/jdbi/v3/core/statement/ArgumentBinder.java#L174
Apparently, the object to be bound must implement the Argument interface
(Add details if you feel like it)
The solution is to use InputStreamArgument
@SqlUpdate("update samples set file = :file where flag = true")
int updateFile(@Bind("file") InputStreamArgument file);
@SqlUpdate("update samples set file = :file where flag = true")
fun updateFile(@Bind("file") file: InputStreamArgument?): Int
http://jdbi.org/apidocs/org/jdbi/v3/core/argument/InputStreamArgument.html
InputStream as the first argument The second argument is the size of the Stream Pass ASCII or not as the third argument
public InputStreamArgument(InputStream stream,
int length,
boolean ascii)
Parameters:
stream - the stream to bind
length - the length of the stream
ascii - true if the stream is ASCII
Recommended Posts