@Repository
public interface RoundRepository extends CassandraRepository<Round, String> {
List<Round> findByInstanceId(String instanceId, Pageable pageable);
Round findByInstanceIdAndRound(String instanceId, long round);
long countByInstanceId(String instanceId);
}
I have repositories like this. And I want to use them to do async inserts and sync everything else. Can I do it in this style without native queries via AsyncCassandraTemplate? Didn't found any tips
Yes, Spring has a doc on getting Async Query Results via custom repository methods. Basically, you can use the @Async
annotation and then wrap the return type with one of the *Future types.
So in your case, countByInstanceId
might look something like this:
@Async
ListenableFuture<long> countByInstanceId(String instanceId);