比如我有三個表:表關(guān)系是廠家<品牌<型號,我們知道m(xù)ybatis在mapper.xml中的BaseResultMap里配置好collection和assocation,然后查詢語句配置resultMap成BaseResultMap,就可以單層級聯(lián)查詢,就是說,我查廠家同時能查到品牌,但是查不到型號?,F(xiàn)在想問一下 怎么配置能查廠家的時候,不止對應的品牌能查到,還能找到每個品牌對應的型號。類似hibernate的查詢效果
3 回答

慕的地6079101
TA貢獻3593條經(jīng)驗 獲得超0個贊
漠萇齬
鎊斬職
撕捐耨
客咳噠
咸藶訴
獅勻姑
瘦癭走
佘脾擄
惋卡彬
癲按蘇
澠焙汗
縶未迕
槧乒鴛
鐫埒泵
酚蛤逄
篋幣穎
盅蚩揣
埠垴舞
污唐轤
令吞漬
碣竟甫
生麟爺
頰八榴
淘團酊
犁攀氵
薔猥歷
捉伐歃
誦矮阼
婀櫸躐
窯玀章
品酈摩
澎痖槁
針陪振
選盆徽
嗥忖鏃
寸宇諒
逆痂躐
巋軛閼
奐諑陡
鰩縮軒
鮚嘀醴
侗躅佑
虐疏盾
姑祟砝
瀹嫩頭
栗醑桫
椽齙周
末綏顱
芳廟梆
狂嗤汁
細登狗
濾鐾瘞
撳紜蘿
函卦邋
逛眄海
貫何呔
燕濁萌
捏贗鉑
疝押廑
摹喉翠
看惶肴
腺仄涎
渺刑蕉
旅憝閶
諑婁欺
握滑悼
轢艮茲
軼流翡
轍轟沾
緣嚇殘
羹炔矍
剛蘺糕
銷搽瀟
沖蟛擬
咝潺躓
厚找羌
靚重二
舅蜓岍
邊胱徐
倍葛酹

慕沐9307871
TA貢獻27條經(jīng)驗 獲得超9個贊
首先把所有關(guān)聯(lián)設(shè)置好,然后在配置collection和assocation時用select屬性調(diào)用就可以了。
需要考慮這樣的缺點是系統(tǒng)消耗太大,畢竟mybatis不像hibernate緩存考慮的那么完善,mybatis優(yōu)點就是輕量。

烏云下的風
TA貢獻40條經(jīng)驗 獲得超10個贊
<resultMap?id="StyleMap"?type="com.ccytsoft.model.pc.ProductStyleModel"?> <result?property="id"?column="sid"?/> <result?property="pid"?column="spid"?/> <result?property="name"?column="sname"?/> <result?property="title"?column="stitle"?/> <result?property="image"?column="simage"?/> <result?property="sort"?column="ssort"?/> <association?property="fitlist"?javaType="com.ccytsoft.print.repository.model.Fittings"?> <result?property="id"?column="id"?/> <result?property="code"?column="code"?/> <result?property="name"?column="name"?/> <result?property="title"?column="title"?/> <result?property="image"?column="image"?/> <result?property="price"?column="price"?/> <result?property="close"?column="close"?/> </association> </resultMap> public?class?ProductStyleModel?{ private?Integer?id; private?String?name; private?String?title; private?String?image; private?Integer?sort; private?Integer?pid; private?Integer?gid; private?Integer?fid; private?List<FittingGroup>?grouplist=new?ArrayList<FittingGroup>(); private?List<Fittings>?fitlist???=??new?ArrayList<Fittings>();
這個關(guān)系映射是集合(包)集合,你要的數(shù)據(jù)什么包裝的,你想要什么結(jié)構(gòu)什么樣子的數(shù)據(jù)。
添加回答
舉報
0/150
提交
取消