I have ExecutorService service = Executors.newCachedThreadPool()
where I handle user response. I have a very hard-coded sequence of code where I do some SQL queries conditionally (I use CompletableFuture
with ExecutorService
for getting results asynchronously). I follow the principle of executing each sql query in a separate service.execute call but this time using CompletableFuture
for getting result from database makes code much harder to read and maintain.
So I want to know is it better to try to implement it with CompletableFuture
even if it’s not convinient or I can do multiple SQL quiries in 1 service call?
I don’t think It’s necessary to show the actual code here because it’s more of an abstract question.