I have a Entity Order and which has a many to one relation to OrderType entity.
Order{
OrderType type;
}
OrderType{
int id;
String tag; //This field is uniq
}
both are hibernate entities. When I serialise(using jackson) i am getting type as an object in order like
"type" : {
"id":1,
"tag" : "TEST"
}
But I would prefer to show my type as
"type" : "TEST"
Similarly while deserialising i need the OrderType object to be created even the type value will be string equivalent of it.
"type" : "TEST"
should construct
{
"id":1,
"tag" : "TEST"
}
and which has to be an hibernate object mapped by unique field tag, And incase the string haven't present need to thrown an exception.
Can somebody suggest me the best way to achieve it.