Closed RolandOne closed 5 years ago
Hi @RolandOne,
We highly recommend using AWS AppSync to talk to DynamoDB, because it does a much better job handling online vs offline and providing real-time data. Please have a look at this guide: https://aws-amplify.github.io/docs/android/api and let us know if you can use AppSync instead.
For the specific issue you are seeing, can you post the configuration of your DynamoDB table? Looks like 1 is not a valid hash key.
Hi @muellerfr I'll take a look at AppSync for future apps. For now I'm trying to create something simple for my personal project and so far the tutorial I linked above seems to be have the least amount of setup.
Here is my table configuration which I copied from the AWS DynamoDB console. Table name billnumber Primary partition key seq (Number) Primary sort key number (Number) Point-in-time recovery DISABLEDEnable Encryption DISABLED Time to live attribute DISABLEDManage TTL Table status Active Creation date November 13, 2018 at 5:54:10 PM UTC+8 UTC: November 13, 2018 at 9:54:10 AM UTC
Local: November 13, 2018 at 5:54:10 PM UTC+8
Region (Singapore): November 13, 2018 at 5:54:10 PM UTC+8
Provisioned read capacity units 5 (Auto Scaling Disabled) Provisioned write capacity units 5 (Auto Scaling Disabled) Last decrease time - Last increase time - Storage size (in bytes) 28.00 bytes Item count 2 Region Asia Pacific (Singapore) Amazon Resource Name (ARN) arn:aws:dynamodb:ap-southeast-1:707882515706:table/billnumber
@RolandOne Can you try new Primitive(1)
where you pass in 1
without the string?
@kvasukib I've tried that. Doesnt work returns same error
@RolandOne DynamoDB supports two types of primary keys, a Hash Key and a Hash and Range Key. A Hash Key consists of a single attribute that uniquely identifies an item. A Hash and Range Key consists of two attributes that together, uniquely identify an item. In your table, can you find what did you set as the primary key? Is just 'seq' your hash key?
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
Hi I'm trying to make a simple adnroid app that works with dynamodb and following through this tutorial: link
I have been able to connect with the dbClient and access the table. I can successfully perform the dbTable.putItem and also other methods like dbTable.getTableDescription.
I'm having trouble understanding how to execute and dbTable.getItem method which requires a Primitive as an input. I don't quite understand how to use the Hashkey or primary key.
My table looks like this: Image Link
When I execute this line of code:
Document doc = dbTable.getItem(new Primitive("1")); where 1 is the value of the first value in the table.
I get this error.
java.lang.IllegalStateException: hash key type does not match the one in table defination at com.amazonaws.mobileconnectors.dynamodbv2.document.Table.makeKey(Table.java:720) at com.amazonaws.mobileconnectors.dynamodbv2.document.Table.getItem(Table.java:298) at com.example.user.dynamodb.MainActivity$1.run(MainActivity.java:65)