Author | Message |
---|---|
nhthanh87
Posts: 13
|
Posted 22:28 May 08, 2012 |
I want to get instructors for each section by: List<User> instructors = section.getInstructors(); models.put( "instructors", instructors); Then, in JSP page I retrieve by:
<c:forEach var="instructor" items="${instructors}"> I run to LazyInitializationException, and don't know how to fix it. Anyone experienced this error? org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: csns.model.academics.Section.instructors, no session or session was closed |
cysun
Posts: 2935
|
Posted 22:36 May 08, 2012 |
Check out web.xml - there's a "jpaFilter" there which is responsible for keeping the Hibernate session open until the view is rendered. Right now the filter only filters the "*.html" URL pattern. You need to add another URL pattern (presumably "/sites/*") for the URLs you use. |
nhthanh87
Posts: 13
|
Posted 22:45 May 08, 2012 |
It works. Thanks. |
Fatemah
Posts: 59
|
Posted 18:39 May 09, 2012 |
Thank you so much for posting this question. It saves my time! |
nhthanh87
Posts: 13
|
Posted 19:41 May 09, 2012 |
Today, I get this exception again when I try to save a transaction. Let's say an instructor want to add a block from jsp page, and I want to save it in servlet. Here what I have in my servlet:
site.getBlocks().add(block); siteDao.save(site); I'm not sure it's still related to url pattern or not. Any ideas?
|