Cyclic/Recursive Error between parent child relation while using Jackson as data binding
Issue
-
While ORM frameworks are being used like Hibernate to generate JSON of the entities, and bi-directional mappings are being defined between such entities, then following errors is being thrown in the logs.
org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) -
We are using Hibernate Persistence API with Jackson JSON api for data binding. There is
one-to-onedependency between two different entities and while saving the data its working fine but while trying to retrieve the data its getting following recursive error.
org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: org.redhat.model.Model["modelDetail"]->org.redhat.model.ModelDetail["model"]->org.redhat.model.Model["modelDetail"]->org.redhat.model.ModelDetail["model"]-
- Here,
Modelis Parent entity andModelDetailis child entity and there is one to one mapping between these two entities.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- JBoss Hibernate 4.x
- Jackson 1.6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.