title: Circular Json serializing
body: <p>i have a javaEE application with two entities which gets persistet in a database. both entities have a bi-directional association.</p>
  
  <p>First Entity:</p>
  
  <pre><code>@Entity
  @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope=Child.class)
  public class Child implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @OneToOne(fetch= FetchType.LAZY)
      private Father father;
  }
  </code></pre>
  
  <p>Second Entity</p>
  
  <pre><code>@Entity
  @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope=Father.class)
  public class Father implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @OneToOne(fetch= FetchType.LAZY)
      private Child child;
  }
  </code></pre>
  
  <p>Both are exposed via ressources like:</p>
  
  <pre><code>@Path("father")
  @Stateless
  public class FatherResource{
  
      @Context
      private UriInfo uri;
  
      @Inject FatherDao fatherDao;
  
      public FatherResource() {
      }
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public List&lt;Father&gt; getFathers() {
          //TODO return proper representation object
          return fatherDoa.getFathers();
      }
  }
  </code></pre>
  
  <p>There is also a DAO which just gets the Father-Object from the database.</p>
  
  <p>The problem is now, that i get a circular json structure.
  so something like:</p>
  
  <pre><code>{ "id":"1", "child": {"id":"1", "father": {"id":"1", "child":{"id":"1", [...] 
  </code></pre>
  
  <p>I just want to see the child once.</p>
  
  <p>I tried to use:</p>
  
  <pre><code>@JsonIgnoreProperties({"child"})  //above the class
  @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")  //above the class
  @JsonIgnore    //above the property
  </code></pre>
  
  <p>what i want to get is:</p>
  
  <pre><code>{ "id":"1", "child": {"id":"1"}}
  </code></pre>
  
  <p>I'm using </p>
  
  <pre><code>JDK 7
  JaxRS
  Jackson
  Hibernate/Eclipselink
  Glassfish 4.0
  </code></pre>
  
  <hr>
  
  <p>another test which doesn't work:</p>
  
  <pre><code>@Entity
  @JsonSerialize
  @JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id", scope=Object.class)
  public class Father implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @OneToOne(fetch= FetchType.LAZY)
      private Child child;
  }
  </code></pre>
  
  <hr>
  
  <p>ApplicationConfig.java:</p>
  
  <pre><code>public class ApplicationConfig extends Application {
  
  @Override
  public Set&lt;Class&lt;?&gt;&gt; getClasses() {
      Set&lt;Class&lt;?&gt;&gt; resources = new java.util.HashSet&lt;Class&lt;?&gt;&gt;();
      // following code can be used to customize Jersey 2.0 JSON provider:
  
      try {
          Class jsonProvider = Class.forName("org.glassfish.jersey.jackson.JacksonFeature");
  
      } //...
  //..
  </code></pre>
  
  <p>beans.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
         bean-discovery-mode="annotated"&gt;
  &lt;/beans&gt;
  </code></pre>