Hi,
I have problem with Deserialization of entities with association.
The entities are as follows:
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = Process.class)
public class Process implements Serializable {
// some properties here
private UUID id;
private List<User> users = new ArrayList<>();
private List<ProcessHistory> processHistorySet = new ArrayList<>();
private List<AnsweredQuestionnaire> answeredQuestionnaires = new ArrayList<>();
}
public class ProcessHistory implements Serializable {
private UUID id;
@JsonIgnore
private Process process;
private User user;
}
@JsonIdentityInfo(generator= ObjectIdGenerators.UUIDGenerator.class, property = "id", scope = AnsweredQuestionnaire.class)
public class AnsweredQuestionnaire implements Serializable {
private UUID id;
private Process process;
}
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = User.class)
public class User implements Serializable {
private UUID id;
private List<Process> processes = new ArrayList<>();
}
Using the entities with association will cause some problem during dserialization and cause the following error :
com.fasterxml.jackson.databind.JsonMappingException: Already had POJO for id (java.util.UUID)
[[ObjectId: key=4c3cb331-bbbc-4105-bc3e-ddca3fea485d, type=com.fasterxml.jackson.databind.deser.impl.PropertyBasedObjectIdGenerator, scope=com.app.User]]
(through reference chain: com.app.User["processes"]->java.util.ArrayList[0]->com.app.Process["users"]->java.util.ArrayList[0]->com.app.User["id"])
java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Already had POJO for id (java.util.UUID)
[[ObjectId: key=4c3cb331-bbbc-4105-bc3e-ddca3fea485d, type=com.fasterxml.jackson.databind.deser.impl.PropertyBasedObjectIdGenerator, scope=com.app.User]]
(through reference chain: com.app.User["processes"]->java.util.ArrayList[0]->com.app.Process["users"]->java.util.ArrayList[0]->com.app.User["id"])
Your help is greatly appreciated.
Thank you.