Working with bi-dirctional JACKSON
<p>first, sorry about my bad english;</p>

<p>Second, I have the following Code: </p>

<pre><code>@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")    

public class UserAccount implements Serializable  {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private List&lt;Venda&gt; vendas;

    }
</code></pre>

<p>And the following:</p>

<pre><code>public class Venda implements Serializable  {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private UserAccount cliente;

    }
</code></pre>

<blockquote>
  <p>So, everything is okay and get the json from serialize on this way (when I ask for an UserAccount):</p>
</blockquote>

<pre><code>[
  {
    "id": 1,    
    "vendas": [
      {
        "id": 1,        
        "cliente": 1,        
      }
    ]
  }
]
</code></pre>

<blockquote>
  <p>And when I ask for a Venda:</p>
</blockquote>

<pre><code>[
  {
    "id": 1,    
    "cliente": {
      "id": 1,      
      "vendas": [
        {
          "id": 1,        
          "cliente": 1         
        }
      ]
    }
  }
]
</code></pre>

<p>The problem is, I don't need the "cliente" information on "vendas"  in the first case, but in the second one I need the "cliente" information, However I don't want his "vendas", cause I already got it before;</p>

<p>I already trid @JsonIgnore and didn't work for me, what should I do?</p>

<p>PS: I'm working with GSON to get the .Class from JSON, and I get a terrible Exception because sometimes cliente is an Object and sometimes is Integer, so if you guys have another solution that makes cliente and vendas don't change their type, i would to know too. :(</p>