michaellavelle / spring-data-dynamodb

Simplifies the development of creating an Amazon DynamoDB-based Java data access layer
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
169 stars 284 forks source link

How to use DynamoDBIndexHashKey and DynamoDBIndexRangeKey #31

Closed jAddict7 closed 4 years ago

jAddict7 commented 10 years ago

I have created a GSI hash and key index in DynamoDB in the name "description-name-index" and I like to sort its data using range key by findBy of hash key. Here is my test code, Domain Class @DynamoDBTable(tableName = "test") public class Test implements Serializable{

private static final long serialVersionUID = 1L;

private String id;
private String description;
private String name;

@DynamoDBIndexHashKey(attributeName="description")
public String getDescription() {
    return tesId;
}

public void setDescription(String description) {
    this.setDescription(description);;
}

@DynamoDBIndexRangeKey(attributeName="name")
public String getName() {
    return name;
}

public void setName(String name) {
    this.setName(name);
}

@DynamoDBHashKey(attributeName="id")
public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

    }

and tries to fetch and sort data using findByDescriptionOrderByNameDesc(@Param("decription") String description, Pageable pageable) and also I tried using @Id and placed index hash and range key in a class but all in vain. Am getting 500 Internal Error but not throwing any message too. Is there any way to use GSI hash and range pair and sort them. Thank you.

derjust commented 8 years ago

Duplicate of #11

As (privately) communicated with @michaellavelle, the project will continue under https://github.com/derjust/spring-data-dynamodb.

derjust commented 8 years ago

Check out https://github.com/derjust/spring-data-dynamodb/wiki/Use-Hash-Range-keys