2

I am using spring-data-aerospike dependency within my spring boot app to interact with Aerospike db. I ran into the follow error while using findAll() method of AerospikeRepository (which is synonymous to the findAll() method provided by CrudRepository).

java.lang.IllegalStateException: Query without a filter will initiate a scan. Since scans are potentially dangerous operations, they are disabled by default in spring-data-aerospike. If you still need to use them, enable them via scansEnabled property in org.springframework.data.aerospike.config.AerospikeDataSettings.

Any leads or pointers is greatly appreciated.

dc-coder
  • 41
  • 2

1 Answers1

2

Leaving the answer for anyone who runs into the same issue.

Here is what I did to resolve the issue.

Referenced the code in org.springframework.data.aerospike.config.AerospikeDataSettings and overrode the bean in my applications Aerospike config class

  *@Bean
  public AerospikeDataSettings aerospikeDataSettings() {
    return AerospikeDataSettings.builder().scansEnabled(true).sendKey(true).build();
  }*
dc-coder
  • 41
  • 2
  • Thanks for sharing your solution! In your case thats true - you need to enable scans in order to run findAll() operation, just wanted to clarify that since scans are by default disabled someone might encounter this exception while trying to run any operation that requires a query on a non primary key field - a "Bin" (for example, findByLastName), in that case a secondary index might be a better option than a scan in term of performance. – Roi Menashe Dec 07 '21 at 09:36