Hibernate在使用JSon返回数据的时候总是出现某些异常net.sf.json.JSONException: There is a cycle in the hierarchy!
        at net.sf.json.util.CycleDetectionStrategy$StrictCycleDetectionStrategy.
handleRepeatedReferenceAsObject(CycleDetectionStrategy.java:97)
        at net.sf.json.JSONObject._fromBean(JSONObject.java:674)
        at net.sf.json.JSONObject.fromObject(JSONObject.java:181)
        at net.sf.json.JSONArray._processValue(JSONArray.java:2381)
        at net.sf.json.JSONArray.processValue(JSONArray.java:2412)
        Truncated. see log file for complete stacktrace这个异常由于Hibernate实体表内出现多表连接的关系,使得JSon出现方法找不到异常 解决办法如下:
JsonConfig cfg = new JsonConfig();
    cfg.setJsonPropertyFilter(new PropertyFilter()
    {
         public boolean apply(Object source, String name, Object value) {
           if(name.equals("contactGroups")||name.equals("contactGroupPersons")) {
             return true;
           } else {
             return false;
          }
        }
       });
把Hibernate返回的List里面的多表进行过滤,重新Json去转换就可以