title: How to overwrite type information when serializing objects with jackson?
body: <p>I'm currently trying to serialize data that I've previously loaded via Hibernate. To recover type information I enabled default typing like this:</p>
  
  <p><code>objectMapper.enableDefaultTyping(DefaultTyping.NON_CONCRETE_AND_ARRAYS,As.PROPERTY);</code></p>
  
  <p>I also added identity-info to my entities via this anotation:</p>
  
  <p><code>@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")</code></p>
  
  <p>However when I deserialize <code>@OneToMany</code>-relations that I have, deserialization fails because the PersistentBag does not have a session at this point. Because my programm is running without a container I can not fix this issue easily. </p>
  
  <p>I'm also aware of the fact that there is this hibernate-datatype module for jackson but this doesn't solve the problem (I guess that module is primaliry used for respecting the LAZY_LOADING-hibernate-property). </p>
  
  <p>So my idea to fix this was to not serialize a <code>PersistentBag</code> but an <code>ArrayList</code> instead. Is there an easy way to do this or do I have to write my own serializer (which I tried but without beeing successful)?</p>