开发者

Problem with Iteration and Set

开发者 https://www.devze.com 2023-02-05 12:33 出处:网络
I have a problem with my program. When i run the program: CourseMaterial crsmPrint = new CourseMaterial();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消