0

I am working with DynamoDB, I am extracting the information of my table "orders" correctly but I just have problems with one.

For example, if I want to get the userID, I got it correctly doing that:

String user_idp = item.get("user").getM().get("user_id").getS();

But if I want get the same for other field called provider I got java.lang.NullPointerException.

String pr = item.get("provider").getM().get("name").getS();

The error that I got is:

There was an unexpected error (type=Internal Server Error, status=500).
No message available
java.lang.NullPointerException: null

Here is the structure:

  "provider": {
    "address": "someadress",
    "name": "somename",
    "phoneNumber": somePhoneNumber,
    "provider_id": "someProviderId"
  }

enter image description here

I am missing something with DynamoDB, can you help me?

Thanks!

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Have you check in debug if it's null the get of provider (is the correct name, right?) or the get of name? What's your table structure? – WoAiNii Apr 05 '20 at 09:42
  • Hi @MatteoZanini thank for your answer, yes I have checked all that you said and I added a picture in the description. – Víctor López Rapado Apr 05 '20 at 10:06
  • It seems everything's ok, so which part result null, in debug? Are you sure that's the row throwing the exception? – WoAiNii Apr 05 '20 at 10:12
  • Hi, yes completely sure, this is the weird thing here. – Víctor López Rapado Apr 05 '20 at 10:25
  • Then it could be the item object null, try to check every part of that row, doing the same logic in more rows, or in debug, to see which part is null – WoAiNii Apr 05 '20 at 11:03
  • Hi, I just resolved, it was a dumb mistake.... ScanRequest scanRequest = new ScanRequest().withTableName(orders").withExclusiveStartKey(lastKeyEvaluated).withAttributesToGet("provider"); I forgot insert the AttributesToGet. I am dumb :). Thanks for your help. – Víctor López Rapado Apr 05 '20 at 16:39

0 Answers0