0

This is my pojo structure which is having a Map as an instance variable

@Document(collection = "notifications")
public class PushNotification {

private String notificationId;
private String title;
private String message;
private PushType pushType;
private PushState pushState;
private String stateData;
private String customIconUrl;
private String bannerImageUrl;
private Set<Long> customerIdSet;
private int expiryTime = 60 * 60 * 24;
private Date pushDateCreated;

private Map<String, PushNotificationBatch> pushBatch;

This is how my pojo stored in Mongo (With PushNotificationBatch value)

{
"_id" : "56",
"_class" : "com.medplus.customer.domain.PushNotification",
"title" : "Mongo DashBoard",
"message" : "Mongo DashBoard",
"pushType" : "REGISTERED_CUSTOMER",
"pushState" : "QUICK_ORDER",
"bannerImageUrl" : "http://127.0.0.1/masters/pushNotification/201611/NOTIF_BANNER_20161130174814417",
"customerIdSet" : [
    NumberLong(28716065),
    NumberLong(22203194),
    NumberLong(28716069),
    NumberLong(28715739),
    NumberLong(25403900),
    NumberLong(28715715),
    NumberLong(28716073)
],
"expiryTime" : 172800,
"pushDateCreated" : ISODate("2016-11-30T12:18:18.448Z"),
"pushBatch" : {
    "0" : {
        "uuid" : "96b2a850-1f92-4f75-924f-2787127ec226",
        "batchStatus" : "SUCCESS"
    }
}
}

This is the response i'm getting which doesn't contain my Map variable

[PushNotification [notificationId=54
 title=Mongo 4
 message=Mongo 4
 pushType=REGISTERED_CUSTOMER
 pushState=REWARD
 stateData=null
 customIconUrl=null
 bannerImageUrl=http://127.0.0.1/masters/imgUrl
 customerIdSet=[27796308
 28716083]
 expiryTime=7200
 pushDateCreated=Wed Nov 30 11:28:56 IST 2016]"
Rohit Gaikwad
  • 3,677
  • 3
  • 17
  • 40
  • Are you using mongo template or mongo repository ? Please add the code to get the collection from mongodb – s7vr Nov 30 '16 at 14:01
  • i am using mongo template...here is the sample snippet Set medplusIds = new HashSet(); medplusIds.add(28716073L); medplusIds.add(28716083L); Query mongoQuery = new Query(Criteria.where("customerIdSet").in(medplusIds)); System.out.println("PushNotification By CustomerIds :"+mongoTemplate.find(mongoQuery,PushNotification.class)); – veeraprathapm Nov 30 '16 at 14:43

0 Answers0