You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where the right side of the Function argument must match the return type of the method. This would make some of the current stream/iterator consumption code much simpler:
List<Something> result = newArrayList();
jdbi.withExtension(SomethingDao.class, dao -> dao.loadAllStuff(stream -> stream.forEach(result::add)));
interfaceSomethingDao {
@SqlQuery("...")
voidloadAllStuff(Consumer<Stream<Something>> consumer);
}
would become
List<Something> result = jdbi.withExtension(SomethingDao.class,
dao -> dao.loadAllStuff(stream -> stream.collect(Collectors.toList())));
interfaceSomethingDao {
@SqlQuery("...")
List<Something> loadAllStuff(Function<Stream<Something>, List<Something>> function);
}
This requires some work in the ResultReturner where the consumer argument detection code is located. It should also enforce the <S, T> T someMethod(Function<S, T> functionArgument) pattern.
The text was updated successfully, but these errors were encountered:
There is a lot of code in SqlCallHandler#createResultTransformer that already does most of the work here. This should be aligned to the code in ResultReturner that deals with all the special cases for the consumers.
Also the SqlCallHandler code should probably not do its own thing for functions and consumers by calling Call#invoke() but use the Call#invoke(Consumer<>) and Call#invoke(Function<>) methods directly
hgschmie
added a commit
to hgschmie/jdbi
that referenced
this issue
Oct 6, 2023
Similar to `Consumer<...>` arguments, a function argument consumes the
results of a SQL query. The return value from applying the function is
returned by the SQL object method. This is especially useful for
collecting and managing streaming data as the function is called while
the database connection is live.
Addresses jdbi#2326
hgschmie
added a commit
to hgschmie/jdbi
that referenced
this issue
Oct 6, 2023
Similar to `Consumer<...>` arguments, a function argument consumes the
results of a SQL query. The return value from applying the function is
returned by the SQL object method. This is especially useful for
collecting and managing streaming data as the function is called while
the database connection is live.
Addresses jdbi#2326
hgschmie
added a commit
to hgschmie/jdbi
that referenced
this issue
Oct 7, 2023
Similar to `Consumer<...>` arguments, a function argument consumes the
results of a SQL query. The return value from applying the function is
returned by the SQL object method. This is especially useful for
collecting and managing streaming data as the function is called while
the database connection is live.
Addresses jdbi#2326
We support
and especially
for methods today. Jdbi should also support
where the right side of the Function argument must match the return type of the method. This would make some of the current stream/iterator consumption code much simpler:
would become
This requires some work in the ResultReturner where the consumer argument detection code is located. It should also enforce the
<S, T> T someMethod(Function<S, T> functionArgument)
pattern.The text was updated successfully, but these errors were encountered: