Cyclic/Recursive Error between parent child relation while using Jackson as data binding

Solution Verified - Updated -

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-one dependency 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, Model is Parent entity and ModelDetail is 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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.