0
votes

Error

"no RANGE key value present"

in dynamoDB spring boot Aplication error even after declaring @DynamoDBRangeKey(attributeName = "")

I tried using java Spring boot AWS dynamo DB library and dynamo DB mapper for connecting my spring boot application with AWS dynamo DB even after declaring @DynamoDBRangeKey(attributeName = "created_millis") where "created_millis" is my short key and "farm_id" is my partition key. If I remove short key the data is coming from DB but the moment I add @DynamoDBRangeKey(attributeName = "created_millis") with code is showing

"There was an unexpected error (type=Internal Server Error, status=500).SolarFarmData[created_millis]: no RANGE key value present"

@DynamoDBTable(tableName = "solar_farm_data")
public class SolarFarmData {
    @Id
    private String farmId;

    private Double ambientTemperature;

    private Long createdMillis;

@DynamoDBHashKey(attributeName = "farm_id")
    public String getFarmId() {
        return farmId;
    }

    public void setFarmId(String farmId) {
        this.farmId = farmId;
    }
    @DynamoDBRangeKey(attributeName = "created_millis")
    public Long getCreatedMillis() {
        return createdMillis;
    }

    public void setCreatedMillis(Long createdMillis) {
        this.createdMillis = createdMillis;
    }
    @DynamoDBAttribute(attributeName = "ambient_temperature")
    public Double getAmbientTemperature() {
        return ambientTemperature;
    }

    public void setAmbientTemperature(Double ambientTemperature) {
        this.ambientTemperature = ambientTemperature;
    }
}
1

1 Answers

0
votes
This will work once you start mapping your "created_millis" which is used here as a short key.

UserCrudDaoImpl  Class
@Override
       public SolarFarmData readUser(String farmId, Long millis) {
             return dynamoDBMapper.load(SolarFarmData.class, farmId, millis); //added millis here for the query.
       }

along with this please change Dao, Service, ServiceImpl, and Controller.