java - Get Hibernate Initialized object in JSP -


i have list of objects (jpassatempos) , i'm tring initialize them

       session session = this.sessionfactory.getcurrentsession();         list<jpassatempos> list = (list<jpassatempos>) session.createquery("select jpassatempos  jcodigos c c.jconcorrentes.id=? group c.jpassatempos.id order c.jpassatempos.datafim desc").setparameter(0, id).list();         for(int =0; i< list.size(); i++){            hibernate.initialize(list.get(i).getjpatrocinadorespassatemposes());        }           return list; 

and populated when try call them on jsp page:

  ${passatempo.jpatrocinadorespassatemposes.toarray()[0].id} 

it gives me following error:

http status 500 - javax.servlet.servletexception:  javax.servlet.jsp.jspexception: javax.servlet.jsp.jspexception:  javax.servlet.jsp.jspexception: org.hibernate.lazyinitializationexception:  failed lazily initialize collection of role:  ...jpassatempos.jpatrocinadorespassatemposes, not initialize proxy - no session 

any appreciated.

this error says : in jsp, can not hibernate session. mean object not attached session.

see hibernate life cycle more details : https://stackoverflow.com/a/8113456/1326692

you should pass list server side jsp this,

request.setattribute("mylistname", list); 

and access using jstl.

more details : https://stackoverflow.com/a/2148672/1326692


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -