调用ajax,返回json, 报异常 java.lang.OutOfMemoryError: Java heap space

hibernate 双向多对多或一对多 通过json转换时出现死循环,导致内存溢出。


解决方案1:过滤        

       JsonConfig jsonConfig=new JsonConfig();
       jsonConfig.setExcludes(new String[]{"tblExamRecords","tblExamAnswers","tblExamOptions"});
       jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
     
       JSONArray jsonArray=JSONArray.fromObject(list,jsonConfig);
     

方案2:将双向关系改成单向

你可能感兴趣的:(java,json,Ajax,Hibernate,outofmemery)