title: How to serialize lazy loaded entities with jackson module hibernate?
body: <p>I`m trying to build an application with angularjs and springmvc.I have two classes Province and Comunidad. :</p>
  
  <pre><code>@Entity(name="Provincia")
  @Table(name="T_PROVINCIA")
  public class Provincia implements Serializable{
  
  
  private String idProvincia;
  private String nombre;    
  private Comunidad refComunidad;
  
  public Provincia() {
  }
  
  @Id
  @TableGenerator(name="provinciaGen",
                  table="T_GENERATOR",
                  pkColumnName="ID_GENERATOR",
                  pkColumnValue="ID_PROVINCIA",
                  valueColumnName="ID_VALUE")
  @GeneratedValue(generator="provinciaGen",strategy=GenerationType.TABLE)
  @Column(name="ID_PROVINCIA")
  public String getIdProvincia() {
      return idProvincia;
  }
  
  @Column(name="NOMBRE")
  public String getNombre() {
      return nombre;
  }
  
  @ManyToOne(targetEntity=Comunidad.class, fetch=FetchType.LAZY)
  @JoinColumn(name="ID_COMUNIDAD")
  public Comunidad getRefComunidad() {
      return refComunidad;
  }
  setters
  .....
  .....
  }
  
  @Entity(name="Comunidad")
  @Table(name="T_COMUNIDAD")
  public class Comunidad implements Serializable{
  
  @Id   
  @TableGenerator(name="comunidadGen",
                  table="T_GENERATOR",
                  pkColumnName="ID_GENERATOR",
                  pkColumnValue="ID_COMUNIDAD",
                  valueColumnName="ID_VALUE")
  @GeneratedValue(generator="comunidadGen",strategy=GenerationType.TABLE)
  @Column(name="ID_COMUNIDAD")
  private String idComunidad;
  
  @Column(name="NOMBRE")
  private String nombre;
  
  @Column(name="SHORTNAME")
  private String shortName;
  
  public Comunidad() {
  }
  
  getters and setters
  ...............
  }
  </code></pre>
  
  <p>In my controller:</p>
  
  <pre><code>@RequestMapping("/userlist.json")
  public @ResponseBody List&lt;Provincia&gt; getUserList(){
      return this.provinciaService.loadAllProvincias();
  }
  </code></pre>
  
  <p>And I get that error:
      /*
      No serializer found for class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer and<br>
      no properties discovered to create BeanSerializer (to avoid exception, disable<br>
      SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: 
      java.util.ArrayList[0]->admin.domain.Provincia["refComunidad"]-&lt;
      admin.domain.Comunidad$$EnhancerByCGLIB$$68ea9e6f["hibernateLazyInitializer"])
      */   </p>
  
  <p>I have read on github about jackson module hibernate is a good choice to solve the<br>
  problem : <a href="https://github.com/FasterXML/jackson-module-hibernate" rel="noreferrer">https://github.com/FasterXML/jackson-module-hibernate</a>.
  I included the jackson module hibernate dependency in my pom.xml </p>
  
  <pre><code>    &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-datatype-hibernate4&lt;/artifactId&gt;
        &lt;version&gt;2.2.0&lt;/version&gt;
  &lt;/dependency&gt; 
  </code></pre>
  
  <p>But I don't know where configure the "Hibernate4Module.Feature.FORCE_LAZY_LOADING,true".
  I try to follow the indications from that page <a href="http://blog.pastelstudios.com/2012/03/12/spring-3-1-hibernate-4-jackson-module-hibernate/" rel="noreferrer">http://blog.pastelstudios.com/2012/03/12/spring-3-1-hibernate-4-jackson-module-hibernate/</a></p>
  
  <p>but I obtain the same error.</p>
  
  <p>Is there somebody who can help me with an easy example please?</p>