Jackson JSON serialization, recursion avoidance by level defining

I recently encountered a similar problem: Jackson – serialization of entities with birectional relationships (avoiding cycles)

So the solution is to upgrade to Jackson 2.0, and add to classes the following annotation:

@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, 
                  property = "@id")
public class SomeEntityClass ...

This works perfectly.

Leave a Comment