jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy
来源:互联网 发布:手机淘宝订单无故消失 编辑:程序博客网 时间:2024/05/17 08:57
这个问题一看就是hibernate的关联问题,在处理json的时候,没有能够转换正确,话不多说,先上代码
List<TrLinePicture> respicList=this.commonMng.findByProperties(TrLinePicture.class, new String[]{"trLineInfo.id"}, new Object[]{id},new String[]{"orderNum"},new String[]{"asc"});
JsonConfig config=new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
public boolean apply(Object arg0, String arg1, Object arg2) {
if(arg1.equals("trLineInfo")){//过滤掉trLineInfo属性
return true;
}else{
return false;
}
}
});
JSONArray jsonArray=JSONArray.fromObject(respicList,config);
这边的需求是线路主表、以及线路图片子表,具体的子表配置如下
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ldcms.ld.entity.travel">
<class name="TrLinePicture" table="tr_line_pictures" dynamic-update="true">
<meta attribute="sync-DAO">false</meta>
<cache usage="read-write"/>
<id name="id" type="java.lang.Integer" column="pk_pic_id"><generator class="sequence"><param name="sequence">TR_LINE_PICTURES_SEQ</param></generator></id>
<property name="picPath" column="pic_path" type="string" not-null="false" length="30"/>
<property name="orderNum" column="order_num" type="integer" not-null="false" length="10"/>
<property name="isTitlePic" column="is_title_pic" type="string" not-null="true" length="1"/>
<many-to-one name="trLineInfo" column="fk_line_info_id" class="TrLineInfo" not-null="true"></many-to-one>
</class>
</hibernate-mapping>
同时在主表(线路表)上也配置了线路图片的关联关系
此时是双向关联,当你在JSONArray.fromObject 子表 的时候,如果不去除主表的配置属性,此时会出现死循环
所以需要上述代码进行处理,所以结果就ok啦!!
- jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy
- jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy
- jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy
- jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy!
- Json解析时出现net.sf.json.JSONException: There is a cycle in the hierarchy!42
- json中net.sf.json.JSONException: There is a cycle in the hierarchy!的解决
- net.sf.json.JSONException: There is a cycle in the hierarchy!
- net.sf.json.JSONException: There is a cycle in the hierarchy异常,解决方法
- net.sf.json.JSONException: There is a cycle in the hierarchy!
- net.sf.json.JSONException: There is a cycle in the hierarchy异常的解决方法
- net.sf.json.JSONException: There is a cycle in the hierarchy!
- net.sf.json.JSONException: There is a cycle in the hierarchy
- net.sf.json.JSONException: There is a cycle in the hierarchy!
- net.sf.json.JSONException: There is a cycle in the hierarchy!错误解决方案
- net.sf.json.JSONException: There is a cycle in the hierarchy
- net.sf.json.JSONException: There is a cycle in the hierarchy!
- net.sf.json.JSONException: There is a cycle in the hierarchy!
- net.sf.json.JSONException: There is a cycle in the hierarchy! 异常
- Android开发的环境搭建
- 给群里的哥们写的sql(row_number、rank、dense_rank)
- c/s架构和b/s架构的比较
- ADFS3.0 Customizing the AD FS Sign-in Pages
- 获取文件夹的大小(大小为字节数)
- jQuery调用JSON时,net.sf.json.JSONException: There is a cycle in the hierarchy
- oracle自动清理archivelog文件
- 易车网络汽车配件
- php 防止sql注入
- swift tableview 滚动到指定行列
- 天气查询接口演示代码
- Linux下无法挂载U盘
- 备份
- Ejabberd服务器配置说明文档