6 Replies Latest reply on Mar 10, 2010 3:51 PM by getboa

    javassist.JavassistLazyInitializer exception when Querying

      Hi y'all,

      I'm struggling to solve this lazy issue I hope you guys could help me out.
      This is how i'm trying to do the query:

       

      AuditReader reader = AuditReaderFactory.get(hibernateSession);

      AuditQuery query = reader.createQuery().forRevisionsOfEntity(Product.class, false, false);

      query.add(AuditEntity.property("situation").eq(situationParam));

      query.add(AuditEntity.relatedId("sector").eq(code));

      query.add(AuditEntity.revisionProperty("date").between(dataInicialTmp.getTime(), dataFinalTmp.getTime()));
      List list = query.getResultList();

       

      the intention of this query is to get all products with the given situation per sector in a range of date

       

      If i call the System.out.println(list.size()); of this list it shows the real result, but when trying to show the results on my page, an exception is thrown:
      org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:187)

      com.technology.entity.Box_$$_javassist_26.writeReplace(Box_$$_javassist_26.java)


      Product.java

      @Entity

      @Audited

      public class Product implements Serializable{

       

                  private Box box;

                  private Sector sector;

       

                  @ManyToOne(cascade={})

                  @JoinColumn(.........)

                  public Box getBox() {

                        return box;

                  }

       

                  public void setBox(Box box){

                          this.box = box;

                  }
                  @OneToOne(fetch=FetchType.EAGER)

                  @JoinColumn(..........)

                  public Sector getSector() {

                        return sector;

                  }

                  public void setSector(Sector sector){

                          this.sector = sector;

                  }

      }

       

      @Entity

      @Audited

      public class Box implements Serializable{

       

                  @OneToMany(mappedBy = "box")

                  private Set<Product> products;

                  }

                   // getters and setters

      }

       

      Any idea of what i'm doing wrong ??? Any comments/ideas are welcome
      thanks in advance