Hi everyone!!! I don't understand why when i run the following code (using DAO pattern):
Hobby hobby = hobbyDao.find(h.getMyHobbyId()); System.out.println("Hobby = " + hobby.getHobby()); System.out.println("Years of practice = "+hobby.getYearIstartedThisHobby()); it throws an exception: GRAVE: could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at Hobby$$EnhancerByCGLIB$$cb36960a.getHobby(<generated>) at Main.main(Main.java:24) Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at Hobby$$EnhancerByCGLIB$$cb36960a.getHobby(<generated>) at Main.main(Main.java:24) Java Result: 1 The only way i figured out to avoid this is to DISABLED Lazy initialization by setting in Hobby.hbm.xml: <class name="Hobby" table="hobby" lazy="false"> ... The strange thing is that this code is based on "HibernateSimpleDaoInterface" project from LAB-3514 where Lazy="false" doesn't exist in Event.hbm.xml. I expecting that someone could clarify this. Thanks in advance! Federico Miralles Mendoza, ARGENTINA --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en -~----------~----~----~----~------~----~------~--~---