title: AWS DynamoDB: Could not unconvert attribute error
body: <p>I have an issuse and I can't handle it. I've created CRUD methods for example in KitchenService. I have methods like addProduct etc and these works fine.. But I have Recipe class where I'm using Product class field.. In this case I have huge problems. </p>
  
  <p>My addRecipe method:</p>
  
  <pre><code>public Recipe addRecipe (Recipe recipe){
  
      List&lt;RecipeElement&gt; recipeElements = recipe.getRecipeElements();
      for (RecipeElement recipeElement : recipeElements) {
          String id = recipeElement.getProduct().getId();
          Product product = databaseController.get(Product.class, id);
          recipeElement.setProduct(product);
      }
  
      databaseController.saveRecipe(recipe);
      logger.log("Recipe created");
  
      return recipe;
  </code></pre>
  
  <p>Build succesfull so I want to test it in POSTMAN, that's how look JSON witch I'm sending:</p>
  
  <pre><code>{"id":null,"name":"test3","labels":["GLUTEN_FREE"],"author":{"name":"Plejer Annołn","id":"testID2"},"media":{"name":"heheszki","url":"http://blabla.pl","mediaType":"IMAGE"},"recipeElements":[{"product":{"id":"ecacaf36-29a2-41c6-942e-be5a715ed094"},"weight":"100"}],"approved":false}
  </code></pre>
  
  <p>And then I get "message": "Internal server error" so I'm checking logs, that's what I found there:</p>
  
  <pre><code>Product[Media]; could not unconvert attribute: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException
  
  Caused by: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: could not invoke public void pl.javamill.model.kitchen.Product.setMedia(pl.javamill.model.common.Media) on class pl.kitchen.Product with value {name=heheszki, url=http://blabla.pl, mediaType=IMAGE} of type class java.util.LinkedHashMap
  </code></pre>
  
  <p>This is how look Recipe Class:</p>
  
  <pre><code>@DynamoDBTable(tableName = "recipe")
  public class Recipe extends Request {
  /**
   * Id of kitchen content
   */
  private String id;
  /**
   * Name of recipe
   */
  private String name;
  
  /**
   * Labels of product for example gluten fee product
   */
  private List&lt;KitchenLabel&gt; labels;
  
  /**
   * Author of content.
   */
  private Author author;
  
  /**
   * Address of content image.
   */
  private Media media;
  
  private Boolean approved;
  
  private List&lt;RecipeElement&gt; recipeElements;
  
  @DynamoDBHashKey(attributeName = "id")
  @DynamoDBAutoGeneratedKey
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  @DynamoDBAttribute(attributeName = "Name")
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  @DynamoDBTypeConverted(converter = EnumConverter.class)
  @DynamoDBAttribute(attributeName = "Labels")
  public List&lt;KitchenLabel&gt; getLabels() {
      return labels;
  }
  
  public void setLabels(List&lt;KitchenLabel&gt; labels) {
      this.labels = labels;
  }
  
  @DynamoDBTypeConverted(converter = ObjectConverter.class)
  @DynamoDBAttribute(attributeName = "Author")
  public Author getAuthor() {
      return author;
  }
  
  public void setAuthor(Author author) {
      this.author = author;
  }
  
  @DynamoDBTypeConverted(converter = ObjectConverter.class)
  @DynamoDBAttribute(attributeName = "Media")
  public Media getMedia() {
      return media;
  }
  
  public void setMedia(Media media) {
      this.media = media;
  }
  
  @DynamoDBAttribute(attributeName = "Approved")
  public Boolean getApproved() {
      return approved;
  }
  
  public void setApproved(Boolean approved) {
      this.approved = approved;
  }
  
  @DynamoDBTypeConverted(converter = ObjectConverter.class)
  @DynamoDBAttribute(attributeName = "RecipeElements")
  public List&lt;RecipeElement&gt; getRecipeElements() {
      return recipeElements;
  }
  
  public void setRecipeElements(List&lt;RecipeElement&gt; recipeElements) {
      this.recipeElements = recipeElements;
  }
  </code></pre>
  
  <p>RecipeElement class:</p>
  
  <pre><code>public class RecipeElement {
  
  
  private Product product;
  private Integer weight;
  
  @DynamoDBTypeConverted(converter = ObjectConverter.class)
  @DynamoDBHashKey(attributeName = "product")
  public Product getProduct() {
      return product;
  }
  
  public void setProduct(Product product) {
          this.product = product;
      }
  
      public Integer getWeight() {
          return weight;
      }
  
      public void setWeight(Integer weight) {
          this.weight = weight;
      }
  }
  </code></pre>
  
  <p>And Product class:</p>
  
  <pre><code>@DynamoDBTable(tableName = "product")
  public class Product extends Request {
      /**
       * Id of kitchen content
       */
      private String id;
  
      /**
       * Name of product
       */
      private String name;
  
      /**
       * Calories in 100g
       */
      private Integer calories;
  
      /**
       * Fat in 100g
       */
      private Double fat;
  
      /**
       * Total carbo in 100g
       */
      private Double carbo;
  
      /**
       * Total Protein in 100g
       */
      private Double protein;
  
      /**
       * Labels of product for example gluten fee product
       */
      private List&lt;ProductKind&gt; productKinds;
  
      /**
       * Author of content.
       */
      private Author author;
  
      /**
       * Address of content image.
       */
      private Media media;
  
      private Boolean approved;
  
      @DynamoDBHashKey(attributeName = "id")
      @DynamoDBAutoGeneratedKey
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      @DynamoDBAttribute(attributeName = "Name")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @DynamoDBAttribute(attributeName = "Calories")
      public Integer getCalories() {
          return calories;
      }
  
      public void setCalories(Integer calories) {
          this.calories = calories;
      }
  
      @DynamoDBAttribute(attributeName = "Fat")
      public Double getFat() {
          return fat;
      }
  
      public void setFat(Double fat) {
          this.fat = fat;
      }
  
      @DynamoDBAttribute(attributeName = "Carbo")
      public Double getCarbo() {
          return carbo;
      }
  
      public void setCarbo(Double carbo) {
          this.carbo = carbo;
      }
  
      @DynamoDBAttribute(attributeName = "Protein")
      public Double getProtein() {
          return protein;
      }
  
      public void setProtein(Double protein) {
          this.protein = protein;
      }
  
      @DynamoDBTypeConverted(converter = EnumConverter.class)
      @DynamoDBAttribute(attributeName = "ProductKinds")
      public List&lt;ProductKind&gt; getProductKinds() {
          return productKinds;
      }
  
      public void setProductKinds(List&lt;ProductKind&gt; productKinds) {
          this.productKinds = productKinds;
      }
  
      @DynamoDBTypeConverted(converter = ObjectConverter.class)
      @DynamoDBAttribute(attributeName = "Author")
      public Author getAuthor() {
          return author;
      }
  
      public void setAuthor(Author author) {
          this.author = author;
      }
  
      @DynamoDBTypeConverted(converter = ObjectConverter.class)
      @DynamoDBAttribute(attributeName = "Media")
      public Media getMedia() {
          return media;
      }
  
      public void setMedia(Media media) {
          this.media = media;
      }
  
      @DynamoDBAttribute(attributeName = "Approved")
      public Boolean getApproved() {
          return approved;
      }
  
      public void setApproved(Boolean approved) {
          this.approved = approved;
      }
  </code></pre>
  
  <p>And this is my converter class:</p>
  
  <pre><code>public class ObjectConverter&lt;T extends Object&gt; 
  implements DynamoDBTypeConverter&lt;String, T&gt; {
  
      ObjectMapper objectMapper = new ObjectMapper();
  
      @Override
      public String convert(T object) {
          try {
              return objectMapper.writeValueAsString(object);
          } catch (JsonProcessingException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          throw new IllegalArgumentException("Unable to parse JSON");
      }
  
      @Override
      public T unconvert(String object) {
          try {
              T unconvertedObject = objectMapper.readValue(object, 
                  new TypeReference&lt;T&gt;() {
              });
              return unconvertedObject;
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  }
  </code></pre>
  
  <p>Can someone help me with this issue?</p>