spring-data-dynamodb icon indicating copy to clipboard operation
spring-data-dynamodb copied to clipboard

Annotation @Query does not support Non-String Type

Open qqyycom opened this issue 3 years ago • 0 comments

@Query(filterExpression = "#field = :value", consistentReads = QueryConstants.ConsistentReadMode.EVENTUAL, expressionMappingNames = {@ExpressionAttribute(key = "#field", value = "key")}, expressionMappingValues = {@ExpressionAttribute(key = ":value", parameterName = "key")}) List<RingtoneDO> findByUidAndDeviceId(@Param("uid") String uid, @Param("device_id") String deviceId, @Param("key") Integer key);

Expected Behavior

I want QueryFilter with Number type, But It doesn't support

Actual Behavior

Throws ClassCastException

which happens in {@DynamoDBEntityWithHashAndRangeKeyCriteria} line 216

queryExpression.addExpressionAttributeValuesEntry(value.key(), new AttributeValue(mappedExpressionValues.get(value.parameterName())));

the AttributeValue constructor only support String type value

Steps to Reproduce the Problem

Specifications

  • Spring Data DynamoDB Version: 5.2.5
  • Spring Data Version: 2.5.2
  • AWS SDK Version:
  • Java Version: 8
  • Platform Details:

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.

qqyycom avatar Feb 24 '22 10:02 qqyycom