LazyInitializationException:无法初始化代理

时间:2019-06-14 07:40:58

标签: java hibernate

根据以下代码,当我运行我的get服务时,出现此错误:

>Generating incomplete JSON and org.hibernate.LazyInitializationException: could not initialize proxy

请帮助我解决此错误

List<consumerrequesttable> consumerrequesttablelist=null;
CriteriaBuilder builder = Lpgdao.sessionobj.getCriteriaBuilder();
CriteriaQuery<consumerrequesttable> query = builder.createQuery(consumerrequesttable.class);
Root<consumerrequesttable> root = query.from(consumerrequesttable.class);
query.select(root).where(builder.equal(root.join("contableobj").get("consumerid"), cid));
Query q = Lpgdao.sessionobj.createQuery(query);
consumerrequesttablelist = (List) q.getResultList();
return consumerrequesttablelist ;

SEVERE: Generating incomplete JSON
Jun 14, 2019 12:50:55 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/lpg] threw exception [org.hibernate.LazyInitializationException: could not initialize proxy [org.glassfish.jersey.core.jersey_server.tablemodelclasses.consumertable#ha94578993344] - no Session] with root cause
org.hibernate.LazyInitializationException: could not initialize proxy [org.glassfish.jersey.core.jersey_server.tablemodelclasses.consumertable#ha94578993344] - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:169)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:309)

0 个答案:

没有答案