18
如何修复org.hibernate.LazyInitializationException-无法初始化代理-没有会话
我得到以下异常: Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190) at sei.persistence.wf.entities.Element_$$_jvstc68_47.getNote(Element_$$_jvstc68_47.java) at JSON_to_XML.createBpmnRepresantation(JSON_to_XML.java:139) at JSON_to_XML.main(JSON_to_XML.java:84) 当我尝试从以下几行拨打电话时: Model subProcessModel = getModelByModelGroup(1112); System.out.println(subProcessModel.getElement().getNote()); 我getModelByModelGroup(int modelgroupid)首先实现了这样的方法: public static Model getModelByModelGroup(int modelGroupId, boolean openTransaction) { Session session = SessionFactoryHelper.getSessionFactory().getCurrentSession(); Transaction tx = null; if …