Axon 4.4.2 query all entries with jpa error

query code:
List result = queryGateway.query(IstrAllEventQuerier.builder().build(), ResponseTypes.multipleInstancesOf(IstrEventEntry.class)).join();

query handler:
List result = dataStore.findAll();

and Error Message:
【Caused by: java.lang.IllegalArgumentException: Retrieved response [class java.util.ArrayList] is not convertible to a List of the expected response type [class bank.investment.instruction.jpa.IstrEventEntry]
at org.axonframework.messaging.responsetypes.MultipleInstancesResponseType.convert(
at org.axonframework.messaging.responsetypes.MultipleInstancesResponseType.convert(
at org.axonframework.messaging.responsetypes.ConvertingResponseMessage.getPayload(
at org.axonframework.queryhandling.DefaultQueryGateway.lambda$query$1(
at java.util.concurrent.CompletableFuture.uniAccept(Unknown Source)
at java.util.concurrent.CompletableFuture$UniAccept.tryFire(Unknown Source)
at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.util.concurrent.CompletableFuture.complete(Unknown Source)
at org.axonframework.axonserver.connector.query.AxonServerQueryBus$
at java.util.concurrent.Executors$ Source)
at Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
… 1 more】

can anybody help me?

Hi @1a2B3C, let me try to help you out here.

To be honest, I am not overly clear why you are receiving the given error message at this stage, other than what’s stated through the exception right now…

Would you be able to give more fleshed out sample code of what you are actually doing, whilst using markdown semantics too? The latter should make it clearer what the intend is of your code as code-style indentation will be maintained.

As a means to work further on your end though, I guess you might have misdefined the query handling function. You state all you do is List result = dataStore.findAll();, but you would very likely be returning the result somewhere too. Based on how you are dispatching your query, Axon will expect that there is an @QueryHandler annotated method which as the return type has a List<IstrEventEntry>. As your snippets don’t share the entire specifics of your query handler, it is currently unclear to me whether that’s the problem.

On another note, the query response of IstrEventEntry makes it sounds like your are storing the events and an additional query model alongside the event store. This should not be necessary at all, as you can simply retrieve the events from the event store when you need them by invoking methods directly on the event store.

Lastly, if you would be requiring a “list all events” query to be pushed through a query, you will be having a bad experience as well, mainly due to the size your event store will likely eventually have. So having a form of filter for this query, to not retrieve everything, would be beneficial. Granted, if you really need this query in the first place when there is a perfectly fine Event Store you can use.

Hoping this helps you further @1a2B3C!