spring-data-dynamodb
spring-data-dynamodb copied to clipboard
NotContains is not allowing single parameter as filter
Expected Behavior
NotContains
should return list of Acknowledgements
when acknowledgements
does not contains username
.
public List<Acknowledgement> findAllByAcknowledgementsNotContainsAndActiveIsTrue(String username);
where Acknowledgement:
@DynamoDBTable(tableName = "acknowledgement")
@Getter @Setter @NoArgsConstructor
public class Acknowledgement {
@Id
@DynamoDBHashKey
@DynamoDBAutoGeneratedKey
private String id;
@Field
@DynamoDBAttribute
private List<String> acknowledgements = new ArrayList<>();
...
}
Actual Behavior
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.List (java.lang.String and java.util.List are in module java.base of loader 'bootstrap')
at com.amazonaws.services.dynamodbv2.datamodeling.StandardTypeConverters$Vector$ToList$1.convert(StandardTypeConverters.java:370) ~[aws-java-sdk-dynamodb-1.12.297.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter$DelegateConverter.convert(DynamoDBTypeConverter.java:104) ~[aws-java-sdk-dynamodb-1.12.297.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter$NullSafeConverter.convert(DynamoDBTypeConverter.java:123) ~[aws-java-sdk-dynamodb-1.12.297.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter$ExtendedConverter.convert(DynamoDBTypeConverter.java:83) ~[aws-java-sdk-dynamodb-1.12.297.jar:na]
at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel.convert(DynamoDBMapperFieldModel.java:138) ~[aws-java-sdk-dynamodb-1.12.297.jar:na]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCriteria.getPropertyAttributeValue(AbstractDynamoDBQueryCriteria.java:564) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCriteria.createSingleValueCondition(AbstractDynamoDBQueryCriteria.java:713) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCriteria.withSingleValueCriteria(AbstractDynamoDBQueryCriteria.java:485) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCreator.getItemsProperty(AbstractDynamoDBQueryCreator.java:206) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCreator.addCriteria(AbstractDynamoDBQueryCreator.java:147) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCreator.create(AbstractDynamoDBQueryCreator.java:124) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCreator.create(AbstractDynamoDBQueryCreator.java:50) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:119) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:95) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:81) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.socialsignin.spring.data.dynamodb.repository.query.PartTreeDynamoDBQuery.doCreateQuery(PartTreeDynamoDBQuery.java:58) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQuery.doCreateQueryWithPermissions(AbstractDynamoDBQuery.java:81) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQuery$CollectionExecution.execute(AbstractDynamoDBQuery.java:100) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQuery.execute(AbstractDynamoDBQuery.java:311) ~[spring-data-dynamodb-5.2.5.jar:5.2.5]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.20.jar:5.3.20]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.20.jar:5.3.20]
at com.sun.proxy.$Proxy160.findAllByAcknowledgementsNotContainsAndActiveIsTrue(Unknown Source) ~[na:na]
Steps to Reproduce the Problem
- Execute above code
Specifications
- Spring Data DynamoDB Version: 5.2.5
- Spring Data Version: Neumann-SR9 (spring-data-commons-2.7.0.jar)
- AWS SDK Version: 1.12.297
- Java Version: OpenJDK 64-Bit Server VM Corretto-11.0.16.9.1 (build 11.0.16.1+9-LTS, mixed mode)
- Platform Details: Docker CE on Ubuntu 22.04
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.
Referencing this: https://github.com/boostchicken/spring-data-dynamodb/pull/34 which indicates it should be fixed. What am I missing?