I have a MongoDB collection and document with an embedded array of objects: 'qtyContents'. Populated with test String data for the PoC:
id:5aa2c7b4aaa32bcb1d7cfc93 ean: "05052319711639" qtyContents : Array 0 : Object quantity : "1.1" totalQuantity : "1.2" quantityUom : "1.3" netContents : "1.4" avgMeasure : "1.5" 1 : Object quantity : "2.1" totalQuantity : "2.2" quantityUom : "2.3" netContents : "2.4" avgMeasure : "2.5"
My Entity is:
@Entity
@Indexed
@Table(name = "foodsCosmeticsMedicines")
public class FoodsCosmeticsMedicines implements Serializable {
@ElementCollection
private List<QtyContents> qtyContentsList;
//setters & getters
}
and for 'QtyContents':
@Embeddable
public class QtyContents implements Serializable {
private String quantity;
private String totalQuantity;
private String quantityUom;
private String netContents;
private String avgMeasure;
//setters & getters
}
When I run my unit test I get:
09:44:18,762 INFO [com.notifywell.controller.NOTiFYwellController] (default task-56) >>>>> NOTiFYwellController getAllFoodsCosmeticsMedicinesJSON ..... 09:44:18,764 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56)
getAllFoodsCosmeticsMedicinesJSON = 09:44:18,770 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) getAllFoodsCosmeticsMedicinesJSON foodsCosmeticsMedicinesList = 1 09:44:18,770 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) >>>>> getAllFoodsCosmeticsMedicinesJSON id = 5aa2c7b4aaa32bcb1d7cfc93 09:44:18,770 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) getAllFoodsCosmeticsMedicinesJSON ean = 05052319711639 09:44:18,771 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) >>>>> getAllFoodsCosmeticsMedicinesJSON description = 09:44:18,771 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) >>>>> getAllFoodsCosmeticsMedicinesJSON qtyContents = 0 09:44:18,802 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) [ { "id": "5aa2c7b4aaa32bcb1d7cfc93", "ean": "05052319711639", "description": "" } ]
I get the 'FoodsCosmeticsMedicines' collection of one:
09:44:18,770 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) >>>>> getAllFoodsCosmeticsMedicinesJSON foodsCosmeticsMedicinesList = 1
but the 'qtyContents' array is empty.
09:44:18,771 INFO [com.notifywell.ejb.FoodsCosmeticsMedicinesEJB] (default task-56) >>>>> getAllFoodsCosmeticsMedicinesJSON qtyContents = 0
Where it should have two documents.
Any idea what I'm doing wrong with the annotations for the array/collection?