I'm having an issue with SqlObject working with Consumer<Stream<T>> as a parameter.

Skip to first unread message

Michael Conrad

Jan 18, 2023, 3:41:37 PMJan 18
to jd...@googlegroups.com, Jason Carter
(Crossposted to StackOverflow: https://stackoverflow.com/q/75165002/1341731)

What do I need to do to fix "No Mapper Registered" when trying to Stream a result set from a SqlObject DAO? The method is annotated with @RegisterBeanMapper and the documentation seems incomplete.

According to https://jdbi.org/#_consumer_arguments:

15.1.3. Consumer Arguments

As a special case, it is possible to use a Consumer argument in addition to other bound arguments.

Unless the type T is a Stream or an Iterator, the consumer is executed once for each row in the result set. The static type of parameter T determines the row type.

If the consumer implements Consumer<Iterator>, or Consumer<Stream>, then the consumer is executed once with the Iterator or Stream holding the results. The static type of parameter T determines the mapped row type here as well. When using a consumer argument with an iterator or a stream, Jdbi will manage and close them after the callback completes.

I'm using the following in a DAO interface:

    @SqlQuery(" SELECT id, title FROM " + TABLE_XML_RECORDS //
        + " WHERE" //
        + "  issuedate IS NULL" //
        + "  AND sort_date <= :issueweek" //
        + "  AND sort_date >= :oldest" //
        + "  AND sort_date IS NOT NULL" //
        + " ORDER BY sort_date DESC")
        void getRecordIdsFor(@Bind("issueweek") LocalDate issueweek, @Bind("oldest") LocalDate oldestSortDate, java.util.function.Consumer<Stream<IdTitle>> consumer);

But I'm getting:

    No mapper registered for type java.util.stream.Stream<clarivate.mariadb.models.IdTitle>

I've tried searching for code snippets to go by, but my search foo is failing and the documentation does not contain a simple concrete example to go by.

Steven Schlansker

Jan 18, 2023, 3:46:44 PMJan 18
to jd...@googlegroups.com, Jason Carter
What version of Jdbi do you use?
This functionality was only added recently, in 3.35.0
> --
> You received this message because you are subscribed to the Google Groups "jDBI" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jdbi+uns...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jdbi/13f25c89-d622-7d8e-dd91-90b32c07e49c%40newsrx.com.

Michael Conrad

Jan 18, 2023, 6:27:00 PMJan 18
to jd...@googlegroups.com

That is likely an issue, I'll test with 3.35.0 and report back.


Michael Conrad

Jan 18, 2023, 7:03:58 PMJan 18
to jd...@googlegroups.com

That fixed my issue.


On 1/18/23 15:46, Steven Schlansker wrote:
Reply all
Reply to author
0 new messages