Furkan Zumrut

[Solution] JAXB Infinitely cycling bidirectional relationship

While we trying to create bidirectional relationship we may get an error which is about infinitely cycling.

These errors can be like that:

If we are using webservice, our client can get error like:

A cycle is detected in the object graph. This will cause infinitely deep XML

Or we can get error in our server logs like:

javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException – with linked exception: [com.sun.istack.internal.SAXException2: A cycle is detected in the object graph. This will cause infinitely …..

 

Solution

We should use @XmlTransient annotion to break this cycle easly.
So, as you see we have two class. AutoCategory and AutoSubCategory. They have bidirectional OneToMany relationship. And we are try to getting categoryid for AutoSubCategory class. And both classes has relationship with Auto class. We should send our categoryid and subcategory to Auto Class. But when we create the relationship we should put @XmlTransient annotion to each getAuto method. Because we have to break cycle we didn’t get infinitely cycling.

 

More from my site

  • Open Source Projects Using Spring Hibernate Technologies
  • org.hibernate.LazyInitializationException: could not initialize proxy – no Session hatası ve çözümü
  • Java Restful Web Servisi oluşturmak
  • Generic Dao ile crud işlemlerini tekrarlamaktan kaçının!
  • Postgresql Hibernate Code Generation Tool
  • java.lang.ClassNotFoundException: javax.transaction.TransactionManager hatası ve çözümü
cycling detected, hibernate bidirectional relationship cycling, infinitely deep xml, jax infinitely cycling, xmltransient
JPA/Hibernate

Recent Posts

  • How to run java jar in Elastic beanstalk with custom jvm parameters? (Procfile)
  • How to change timezone with ebextension in Elastic Beanstalk?
  • Save your money shutting down EC2 Instance with AWS Lambda!
  • Keep your Test Environment more stable with Pre-Branch
  • Getting Started with Scalate: Simple Web Application with Spring MVC

Medium

Pages

  • CV

Categories

  • Android
  • AWS
  • CXF
  • Devops
  • Genel
  • Java
  • Javascript
  • JAX-RS
  • JPA/Hibernate
  • JSF
  • Maven
  • Postgresql
  • Servlet
  • Spring
  • Tomcat

Archives

  • August 2017
  • June 2016
  • October 2015
  • June 2015
  • May 2015
  • April 2015
  • February 2015
  • December 2014
  • November 2014
  • October 2014
  • June 2014
  • May 2014
  • June 2011

Theme created by Mick de Graaf

age of civilization
tank stars