java - How to retrieve a list from DynamoDB? -


im having specific error when running scan expression on table within dynamodb database. there 1 item in projects table of now. item contains project description , list of strings of team mates. when retrieving information project description code prints out correct name of project. when trying retrieve list of team mates same item says list null object reference. can not seem understand why list being returned null. assume permissions have been set within iam console, , database.

below code thread scans table.

  public void run() {                 dynamodbscanexpression scanexpression = new dynamodbscanexpression();   //returns list of items table. each item of project type                 list<project> scanresult=mapper.scan(project.class,scanexpression);  //for each project within scanresult following                 (project project: scanresult){ //retrieve name of team (this portion of code logs project name properly)                     string team=project.getprojectname();                     log.v("team",team.tostring()); //the list being returned 1 line below null??                     list<string> teammates=project.getteammates();                      log.v("teammate", teammates.get(0));                 }              }          };          thread mythread = new thread(runnable);         mythread.start(); 

below code projects class serves template when scanning table. area of issue because project description string being returned properly, list of teammates isnt. perhaps not supposed using list, or list not defined properly, or use of java annotations not done correctly on table !!!! can not find issue

package com.example.varun.finalproject; import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.*;  import java.util.list;  /**  * created varun on 4/10/17.  */ @dynamodbtable(tablename = "sbuprojects")  public class project { private string projectname; private list<string> teammates;     @dynamodbhashkey(attributename = "projectname")     public string getprojectname() {         return projectname;     }      public void setprojectname(string projectname) {         this.projectname = projectname;     }      public list<string> getteammates() {         return teammates;     }      public void setteammates(list teammates) {         this.teammates= teammates;     }      } 

lastly here photo of table , item contains string project description , list of strings teammates. assumed because table determined teammates list should create list when returning teammates.

http://i67.tinypic.com/2qnm58h.jpg
appreciated.

you need set annotation above getteammates() method, similar how set getprojectname() method.

for example, @dynamodbattribute(attributename = "teammates")


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -