多表多對一的級聯關係(tomocat報錯)

2021-08-22 05:59:24 字數 1042 閱讀 8975

報錯資訊:

net.sf.json.jsonexception: there is a cycle in the hierarchy!----好像說表之間死迴圈

解決方法就是: jsonconfig.setexcludes(new string);//去掉某屬性

將關聯之間的物件去掉

(list型別)

/*

* 獲取商品分類

*/public string getallbigtype(httpservletresponse response));//去掉某屬性

jsonarray jsonarray = jsonarray.fromobject(bigtypes,jsonconfig);

oututil.print(jsonarray, response);

return null;

}

(物件型別)      

/*

* 根據商品id查詢資訊**/

public string getspecialpriceorhot(string nid,httpservletresponse response));//去掉某屬性

//可以用這個方法過濾掉物件中存在的一對多的關係

jsonarray jsonarray = jsonarray.fromobject(product,jsonconfig);

oututil.print(jsonarray, response);

return null;

}

、、、、、可以用這個方法過濾掉物件中存在的一對多的關係

解決問題筆記:"products","smalltypes"就是解析json 時 遇到這個字串時,不再解析

實體類的屬性:set 又包含物件,物件又有set ,無限迴圈下去,

例如bigtype類中的屬性

private setsmalltypes = new hashset();

private setproducts = new hashset();

十二 多表的建立及關係 多對多

多對多,在開發中我們一般引入一張中間表,在中間表中存放兩張表的主鍵,一般還會將這兩個主鍵設定成中間表的聯合主鍵 例子 商品和訂單 建立商品表 create table product id int primary key auto increment,name varchar 20 price do...

sql語句之多表關係 一對多 多對多

建立主表 分類表 create table category cid int primary keyauto increment cname varchar 20 建立從表 產品表 create table product pid int primary keyauto increment pnam...

多對多關係的多表關聯查詢

出處 下面我就舉個比較好理解的例子來說明這個概念。學生和學生所選的選修課之間的關係,就符合多對多的關係,怎麼理解呢?乙個學生可能會選擇多門選修課,而,一門選修課則可能會對應多個學生,下面我以此為例子來說明這個問題。alter table stu ref sub add constraint fk s...