I have a problem with my program.
When i run the program:
CourseMaterial crsmPrint = new CourseMaterial();
Iterator<CourseMaterial> itPrint = trs.getAllTrainerCourseMaterial(Integer.parseInt(request.getSession().getAttribute("id").toString())).iterator();
while (itPri开发者_运维百科nt.hasNext()){
crsmPrint = itPrint.next();
Lecture lctPrint = new Lecture();
Iterator<Lecture> itLctPrint = trs.getAllLecture(crsmPrint.getId()).iterator();
while(itLctPrint.hasNext()){
lctPrint = itLctPrint.next();
out.print("<option>"+lctPrint.getId()+"</option>");
}
}
The error is:
failed to lazily initialize a collection of role: lesson.domain.CourseMaterial.lectures, no session or session was closed
There are a problem in my code?
Thanks
Seems like you are using ORM in your application and configured lectures to be loaded lazily. You can either change the config to load them eagerly or iterate the lectures in a transaction.
精彩评论