1

I was new to the spring restful with Jackson and Hibernate OGM. I'm getting JSON format as below from web request

"Order": 
{ 
  "Orderdata": [ {"orderNo" : "1","location":"A"},{"orderNo" : "2","location":"B"},..]
}

Pojo class for order

class Order implements Serializable{
@ElementCollection
private List<OrderData> Orderdata = null;

//getter and setter
}

After inserting the document into MongoDB. I'm getting as below

"Order": {
  "Orderdata": [
    {
      "Orderdata": {"orderNo" : "1","location":"A"}
    },
    {
      "Orderdata": {"orderNo" : "2","location":"B"}
    },
    ...
  ]}

Here I need to avoid the "Orderdata" name inside the each document created. Please help me to resolve this issue.

Karthick Nagarajan
  • 1,327
  • 2
  • 15
  • 27
Viswa
  • 45
  • 1
  • 2
  • 9
  • 2
    Please post the POJO class for OrderData also – Chandan Kumar Sep 25 '17 at 09:38
  • @Embeddable class OrderData implements Serializable{ private String orderNo; private String location; //getter and setter } – Viswa Sep 25 '17 at 09:53
  • Which version of Hibernate OGM are you using? That doesn;'t seem that way it shoudl be mapped on MongoDB. I can only have to explanations for it: you found a bug or some other library on top of OGM is causing the issue. Do you think you could create a test case or a project that I can check to replicate the issue? – Davide D'Alto Sep 26 '17 at 11:03
  • I'm using hibernate-ogm 5.0.0 version. Yes, it's inserting with object name in the member variable on pojo class and I'm creating project. – Viswa Sep 26 '17 at 13:57

0 Answers0