1

Consider the known employee/manager relation ship

public class Employee
{

public Employee manager;
public List<Employee> employees;

}

what i want is a way to marshall an employee such that all the child employees will be marshalled, the parent manager employee also be marshalled. without an infinite cycle loop.

bob-cac
  • 1,272
  • 2
  • 17
  • 35

1 Answers1

3

As explained here, you can use the @XmlIDREF annotation to avoid cyclic references.

Add a unique identifier to your employee and annotate it with @XmlID, and annotate your possible cyclic references with @XmlIDREF :

@XmlRootElement
class Employee {
  @XmlID string id;
  @XmlIDREF Employee manager;
  @XmlIDREF List<Employee> _employees;
}
lelimacon
  • 87
  • 1
  • 9