0

I have currently a big problem with Hibernate and Jackson FasterXML. I have a parent class "Structure Parent" with :

@OneToMany(mappedBy = "structureParent", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<Site> sites = new ArrayList<Site>();

And a site class with

@ManyToOne
@JoinColumn(name = "annualStructureId")
@JsonIgnore
private StructureParent structureParent;

The problem is I can't display the structureParent in the XML because of an infinite loop but I need the structureParent id in my XML. Do you know if I could do that ?

Thank you.

BkSouX
  • 739
  • 5
  • 13
  • 29
  • Read about this feature: Handle bi-directional references using declarative method(s) - http://wiki.fasterxml.com/JacksonFeatureBiDirReferences – Michał Ziober Mar 27 '14 at 23:53

1 Answers1

0

You can select only the foreign key(parent's ID) and show on xml this way(jackson 2.1+)

@JsonProperty(value = "annualStructureId")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true) 
private StructureParent structureParent;
isah
  • 5,221
  • 3
  • 26
  • 36