"das wesentliche element entspricht nicht dem schema" in der Stichprobe von AWS Android SDK
Im folgenden die Anweisung von AWS Android SDK
http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/getting-started-store-query-app-data.html
aber wenn ich die mapper.save()
Methode, es wirft immer
07-10 11:47:28.966: E/AndroidRuntime(2030):
com.amazonaws.AmazonServiceException: The provided key element does not
match the schema (Service: AmazonDynamoDBv2; Status Code: 400;
Error Code: ValidationException; Request ID:
hier ist meine Tabelle :
my Book Modell-code:
package com.example.qingzhong.awssample.dbresources;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBAttribute;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBHashKey;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBIndexHashKey;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBIndexRangeKey;
import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBTable;
/**
* Created by qingzhong on 10/7/15.
*/
@DynamoDBTable(tableName = "Books")
public class Book {
private String title;
private String author;
private int price;
private String isbn;
private Boolean hardCover;
@DynamoDBIndexRangeKey(attributeName = "Title")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@DynamoDBIndexHashKey(attributeName = "Author")
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
@DynamoDBAttribute(attributeName = "Price")
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
@DynamoDBHashKey(attributeName = "ISBN")
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
@DynamoDBAttribute(attributeName = "Hardcover")
public Boolean getHardCover() {
return hardCover;
}
public void setHardCover(Boolean hardCover) {
this.hardCover = hardCover;
}
}
und mein code in der MainActivity , verwenden Sie einfach den mapper.save () - Methode,nichts besonderes:
Ich weiß nicht, was schief geht, da alle benötigten Attribute Hinzugefügt werden, in der Book.class und eigentlich bin ich nach der Anweisung von AWS Mobile SDK
InformationsquelleAutor Qing | 2015-07-10
Du musst angemeldet sein, um einen Kommentar abzugeben.
Schließlich arbeitete ich ihn aus, das Bild aus dem link:
http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/getting-started-store-query-app-data.html
ist eigentlich irreführend, wenn Sie wollen, verwenden Sie die ISBN als hash-Schlüssel in den code, müssen Sie angeben,
1.Wählen Sie Hash als primary key geben.
2.Für die hash-Attribut name, sicherzustellen, dass die Zeichenfolge ausgewählt ist, und geben Sie die ISBN. Klicken Sie Auf Weiter.
http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/dynamodb_om.html
Sie sind sehr willkommen 😉
also, was hast du ändern..?
wählen Sie Hash als primary key geben.
InformationsquelleAutor Qing