这是我的pojo结构,它将Map作为实例变量
@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;
这是我的pojo存储在Mongo中的方式(使用PushNotificationBatch值)
{
"_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"
}
}
}
这是我得到的不包含我的Map变量的响应
[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]"