javaspring-dataignitegridgainapacheignite

Can a SqlFieldsQuery instance be reused multiple times invoking setArgs with different arguments each time?


I am wondering if a SqlFieldsQuery instance can be reused multiple times invoking SqlFieldsQuery#setArgs() with different arguments each time before passing to IgniteCache#query() for cache querying.

I don't see anything in the documentation on this & all the code examples I see seem to create a new instance for the same sql query. In the past I have reused SqlQuery (before its deprecation) repeatedly without any issues. I will try to look at the code to see if I can find a reason, but in the meanwhile I am wondering if someone has any insight on this.

UPDATE: Looking at the source of SqlFieldsQuery it looks like its just a POJO (loosely speaking a bean but without a no-arg constructor).


Solution

  • Yes, it is just a POJO, you can reuse it when the previous query has finished executing and returning results.