title: Using findOne() / findAll() in spring boot for Cassandra DB
body: <p>During code optimization I found few areas where I was using findOne() within for loop –</p>
  
  <pre><code>public List&lt;User&gt; validateUsers(List&lt;String&gt; userIds) {
      List&lt;User&gt; validUsers = new ArrayList&lt;&gt;();
      for ( String userId : userIds) {
          User user = userRepository.findOne(userId); //Network hit :: expensive call
          //Perform validations 
          ...
          //Add valid users to validUsers list
          ...
      }
      return validUsers;
  }
  </code></pre>
  
  <p>Above method takes long time if I pass huge list of users to validate. [for 300 users around 5 sec.]</p>
  
  <p>Then I changed above method to use findAll() and perform validations on result collection -</p>
  
  <pre><code>public List&lt;User&gt; validateUsers(List&lt;String&gt; userIds) {
      List&lt;User&gt; validUsers = new ArrayList&lt;&gt;();
      Iterable&lt;User&gt; itr = userRepository.findAll(userIds); //Only one Network hit
  
      for ( User user : itr) {
  
          //Perform validations 
          ...
          //Add valid users to validUsers list
          ...
      }
      return validUsers;
  }
  </code></pre>
  
  <p>Now for 300 users, results coming in 100 ms.
  Question is: Is there any side effects of using findAll() considering the underlying structure of Cassandra? Also I am using CrudRepository. Should I use CassandraRepository?</p>