[JAVA] In DynamoDB Enhanced Client, I access the index table for some reason

error contents

The error statement is as follows.

java.lang.IllegalArgumentException: A sort key value was supplied for an index that does not support one. Index: $PRIMARY_INDEX

Conclusion

The getter / setter definition for an attribute is incorrect. (Nth defeat ...)

Coping

Set the appropriate getters and setters. Specifically, check the following two points.

--Method name --Argument type

Occurrence Status

In the case of the author, it occurred in the following form.

@DynamoDbBean
@Setter
public class Foo {

  private String name;
  private String date;

  @DynamoDbAttribute("name")
  public String getName() {
    return name;
  }

  @DynamoDbAttribute("date")
  public String getDate() {
    return date;
  }

  public setDate(Date date) {
    this.date = new SimpleDateFormat("yyyy-MM-dd").format(date);
  }

}

The cause is Foo # setDate (Date). You need to set getters and setters for the table metadata. When set with the @DynamoDbAttribute annotation, the method name and argument type must match the field. The field date is defined as String type, but the setter has received Date type. Since the signature is different from the setter generated by Lombock's @Setter annotation, it can coexist, andFoo # setDate (String)is also defined. However, it seems that Foo # setDate (Date) is picked up as the metadata of the table. For some reason, it seems that an error occurs when trying to access the index table.

Recommended Posts

In DynamoDB Enhanced Client, I access the index table for some reason
The strong parameter is true, but for some reason it cannot be saved in the table.
I specified the version and rails new, but for some reason the latest version is included ~
Enum misconfiguration. For some reason, I can't get data from the column specified by Enum ...
When the vagrant command doesn't work for some reason
I translated [Clone method for Java arrays] as the Clone method in Java arrays.
When I made a bar graph with MPAndroidChart, the x-axis label was misaligned for some reason