Quantcast
Channel: User Kunal - Stack Overflow
Viewing all articles
Browse latest Browse all 34

Get Hibernate Initialized object in JSP

$
0
0

I have a list of objects (Jpassatempos) and i'm tring to initialize them

       Session session = this.sessionFactory.getCurrentSession();       List<Jpassatempos> list = (List<Jpassatempos>) session.createQuery("select jpassatempos  from Jcodigos c where c.jconcorrentes.id=? group by c.jpassatempos.id order by c.jpassatempos.dataFim desc").setParameter(0, id).list();       for(int i =0; i< list.size(); i++){           Hibernate.initialize(list.get(i).getJpatrocinadoresPassatemposes());       }        return list;

and they do get populated but when i try to call them on my jsp page:

  ${passatempo.jpatrocinadoresPassatemposes.toArray()[0].id}

it gives me the following error:

HTTP Status 500 - javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ...Jpassatempos.jpatrocinadoresPassatemposes, could not initialize proxy - no Session

Any help is appreciated.


Viewing all articles
Browse latest Browse all 34

Trending Articles