spring-data-dynamodb
spring-data-dynamodb copied to clipboard
Ability to apply filter expressions to Query for Numbers and Boolean fields
With Reference to https://github.com/boostchicken/spring-data-dynamodb/issues/27 and https://github.com/boostchicken/spring-data-dynamodb/wiki/Change-Log
We now have an option to filter the Query Result using filterExpression as below.
With static parameters
@Query(fields = "leaveDate", limit = 1, filterExpression = "contains(#field, :value)", expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")}, expressionMappingValues = {@ExpressionAttribute(key=":value", value = "projection")}) List<User> findByPostCode(String postCode);
With dynamic parameters from methods
@Query(fields = "leaveDate", limit = 1, filterExpression = "contains(#field, :value)",
expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "name")},
expressionMappingValues = {@ExpressionAttribute(key=":value", parameterName = "projection")})
List<User> findByPostCode(@Param("postCode") String postCode, @Param("projection") String projection);
But Is there any option or feature available to filter the result based on a field which is of Type Number and Boolean. Let's say In Table I have Price column of type Number and I want to filter the final result based on Price >=100. Then how can we achieve it with filterExpression as ExpressionAttribute has only key, value and parameterName which all are of type String.
Specifications
- Spring Data DynamoDB Version: 5.2.5
- Spring Data Version: 2.2.4.RELEASE
- AWS SDK Version: 1.11.771
- Java Version: 8
- Platform Details: Windows 10
All those information are logged by org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory
on INFO
level on startup.
Or use java -version
and mvn dependency:tree | grep -E 'spring|aws'
to provide those version numbers.
Hello, I am trying to create a repository using @Query. Below is the sample code. @EnableScan public interface MyCRUDRepository extends CrudRepository<Student, StudentKey> { @Query(filterExpression = "contains(#field, :value)", expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "firstName")}, expressionMappingValues = {@ExpressionAttribute(key=":value", parameterName = "firstName")}) List<Student> findList(@Param("firstName") String firstName); } I am getting the following error: You have defined query method in the repository but you don't have any query lookup strategy defined. The infrastructure apparently does not support query methods!
What could be the reason?
2021-07-11 15:45:34.632 INFO 30940 --- [ main] o.s.s.d.d.r.s.DynamoDBRepositoryFactory : Spring Data DynamoDB Version: 5.2.5 (2.2) 2021-07-11 15:45:34.634 INFO 30940 --- [ main] o.s.s.d.d.r.s.DynamoDBRepositoryFactory : Spring Data Version: 2.0.9.RELEASE 2021-07-11 15:45:34.635 INFO 30940 --- [ main] o.s.s.d.d.r.s.DynamoDBRepositoryFactory : AWS SDK Version: 1.11.771 2021-07-11 15:45:34.635 INFO 30940 --- [ main] o.s.s.d.d.r.s.DynamoDBRepositoryFactory : Java Version: 11.0.4 - OpenJDK 64-Bit Server VM 11.0.4+10-b304.77 2021-07-11 15:45:34.635 INFO 30940 --- [ main] o.s.s.d.d.r.s.DynamoDBRepositoryFactory : Platform Details: Windows 10 10.0 2021-07-11 15:45:34.635 WARN 30940 --- [ main] o.s.s.d.d.r.s.DynamoDBRepositoryFactory : This Spring Data DynamoDB implementation might not be compatible with the available Spring Data classes on the classpath! NoDefClassFoundExceptions or similar might occur! 2021-07-11 15:45:34.823 WARN 30940 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dynamoDbController': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dynamoDbRepository': Unsatisfied dependency expressed through field 'myCRUDRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myCRUDRepository': Invocation of init method failed; nested exception is java.lang.IllegalStateException: You have defined query method in the repository but you don't have any query lookup strategy defined. The infrastructure apparently does not support query methods! 2021-07-11 15:45:34.828 INFO 30940 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]