锘??xml version="1.0" encoding="utf-8" standalone="yes"?>日韩专区视频网站,欧美日韩在线视频一区,在线视频专区http://www.aygfsteel.com/pear/category/16599.htmlzh-cnTue, 27 Feb 2007 17:47:35 GMTTue, 27 Feb 2007 17:47:35 GMT60閲嶆柊瀛︿範(fàn) Hibernate fetch lazy cascade inverse 鍏抽敭瀛?http://www.aygfsteel.com/pear/archive/2006/11/05/79251.htmlpearpearSun, 05 Nov 2006 12:04:00 GMThttp://www.aygfsteel.com/pear/archive/2006/11/05/79251.htmlhttp://www.aygfsteel.com/pear/comments/79251.htmlhttp://www.aygfsteel.com/pear/archive/2006/11/05/79251.html#Feedback0http://www.aygfsteel.com/pear/comments/commentRss/79251.htmlhttp://www.aygfsteel.com/pear/services/trackbacks/79251.htmlHibernate鏈璁╀漢澶村ぇ鐨勫氨鏄闆嗗悎鐨勫姞杞藉艦寮忋?br />涔︾湅浜?jiǎn)N嬈′簡(jiǎn)錛岃繕鏄病鏈夌湡姝g悊瑙ibernate銆傛墍浠ヤ笅鍗堜笓闂ㄥ仛浜?jiǎn)涓媼箣璇曞Q屽閰嶇疆鏂囦歡鐨勬剰鎬濆姞娣變簡(jiǎn)璁よ瘑銆?br />
鍋囪鏈変袱涓〃錛孭hotos(涓錛壜?---聽(tīng) picture(澶氾級(jí)Photo鍖呭惈picture闆嗗悎

緇撹1錛?HQL浠g爜 > fetch錛堥厤緗級(jí) > lazy 錛堥厤緗級(jí)
緇撹2錛?榛樿 lazy="true"
緇撹3錛?fetch 鍜?lazy 涓昏鏄敤鏉ョ駭鑱旀煡璇㈢殑錛屄?tīng)?鑰?cascade 鍜?inverse 涓昏鏄敤鏉ョ駭鑱旀彃鍏ュ拰淇敼鐨?br />緇撹4錛?濡傛灉浣犳槸鐢╯pring鏉ュ府浣犵鐞嗕綘鐨剆ession, 騫朵笖鏄嚜鍔ㄦ彁浜わ紝寤惰繜鍔犺澆灝辯瓑浜庢病鍔犺澆~_~(褰撶劧
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 闄ら潪浣犳墜鍔ㄩ噸鏂版墦寮session鐒跺悗鎵嬪姩Hibernate.initialize(set);鐒跺悗鍏抽棴session.
緇撹5:聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)cascade涓昏鏄畝鍖栦簡(jiǎn)鍦ㄤ唬鐮佷腑鐨勭駭鑱旀洿鏂板拰鍒犻櫎銆?br />j緇撹6錛氳佺埜鍙互鏈夊涓瀛愶紝涓涓瀛愪笉鑳芥湁澶氫釜鑰佺埜錛岃屼笖鑰佺埜璇寸殑綆? 瀛╁瓙鍥寸潃鑰佺埜杞?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)鎵浠hotos鑰佺埜瑕佹湁鏉冨姏鎵浠?cascade聽(tīng)榪欎釜鍏抽敭瀛愰兘鏄佺粰鑰佺埜鐨勶紝聽(tīng)涔熷氨鏄駭鑱旀洿鏂幫紝
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 鑰佺埜鏀瑰浜?jiǎn)锛屽効瀛愪篃寰楄窡鐫鏀癸紝鍛靛懙銆傗滀笉鐒?dòng)灱尀娌℃湁闆惰姳閽卞挴鈥濄?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 鑰孭icture鍎垮瓙鏁翠綋鎸ㄩ獋錛屼絾鏄繕鏄緇存姢鐖跺瓙涔嬮棿鑹ソ鐨勫叧緋伙紝瀵硅佺埜鐧句緷鐧鵑『錛屾墍
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 浠ヨ佺埜灝辮錛屽効瀛愶紝鈥滃叧緋伙紝鐢變綘鏉ョ淮鎶わ紙inverse="true")聽(tīng)錛屼笉鐒跺氨涓嶇粰闆惰姳閽便傚懙銆傗濄?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <set name="pictures" inverse="true" cascade="all">
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <key>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <column name="photosid" not-null="true" />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) </key>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <one-to-many class="girl.domain.Picture" />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) 聽(tīng)聽(tīng)聽(tīng) </set>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
嫻嬭瘯浠g爜錛?br />
聽(tīng)聽(tīng)聽(tīng)Photos p = ps.getById(1);
聽(tīng)聽(tīng)Set<Picture> set = p.getPictures();
聽(tīng)聽(tīng)for(Picture pic : set){
聽(tīng) 聽(tīng)聽(tīng)聽(tīng)System.out.println(pic.getId());
聽(tīng)聽(tīng)}

聽(tīng) 閰嶇疆鏂囦歡鐨勪竴閮ㄥ垎錛?br />聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <set name="pictures" inverse="true" cascade="all" >
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <key>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <column name="photosid" not-null="true" />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) </key>
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) <one-to-many class="girl.domain.Picture" />
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng) </set>

嫻嬭瘯榪囩▼浼?xì)瀵归厤缃枃錃g涓嶆柇淇敼錛氬茍涓斾粠鏉ヤ笉鏇炬墜鍔ㄩ噸鏂版墦寮session

嫻嬭瘯緇撴瀯錛?br />
褰撻厤緗潯浠朵負(fù) lazy=true 涓鍙ユ煡璇?嫻嬭瘯浠g爜涓病鏈夎皟鐢╣etPicture() 聽(tīng)姝e父
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?

lazy=true 涓鍙ユ煡璇?鏈塯etPicture()
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?


lazy=true 涓鍙ユ煡璇⒙?鏈塯etPicture() 騫朵笖璁塊棶浜?jiǎn)閲岄潰鐨勫厓鏁癙icture 涓旀湁寮傚父鎶涘嚭
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?


lazy="false" 涓ゅ彞鏌ヨ聽(tīng) 鑲畾娌¢棶棰橈紝鍥犱負(fù)鍏ㄩ儴鏁版嵁閮戒釜鏌ヤ簡(jiǎn)鍑烘潵 鎵浠ユ庝箞璋冪敤閮芥甯?br />Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?
Hibernate: select pictures0_.photosid as photosid1_, pictures0_.id as id1_, pictures0_.id as id2_0_, pictures0_.photosid as photosid2_0_, pictures0_.name as name2_0_, pictures0_.clicked as clicked2_0_, pictures0_.uploaddate as uploaddate2_0_, pictures0_.size as size2_0_, pictures0_.description as descript7_2_0_, pictures0_.uri as uri2_0_ from super.picture pictures0_ where pictures0_.photosid=?


fetch="join"聽(tīng) 涓鍙ユ煡璇⒙?鏁堟灉 錛濓紳 lazy="false" 鍛靛懙錛屽摢涓晥鐜囬珮錛屾垜灝變笉鐭ラ亾浜?jiǎn)銆傘傘傘傘傘傘傘傘傘傘?br />Hibernate: select photos0_.id as id0_1_, photos0_.userid as userid0_1_, photos0_.typeid as typeid0_1_, photos0_.name as name0_1_, photos0_.createtime as createtime0_1_, photos0_.description as descript6_0_1_, photos0_.faceid as faceid0_1_, photos0_.uri as uri0_1_, pictures1_.photosid as photosid3_, pictures1_.id as id3_, pictures1_.id as id2_0_, pictures1_.photosid as photosid2_0_, pictures1_.name as name2_0_, pictures1_.clicked as clicked2_0_, pictures1_.uploaddate as uploaddate2_0_, pictures1_.size as size2_0_, pictures1_.description as descript7_2_0_, pictures1_.uri as uri2_0_ from super.photos photos0_ left outer join super.picture pictures1_ on photos0_.id=pictures1_.photosid where photos0_.id=?

涓嶅姞fetch錛?join" 涓鍙ユ煡璇⒙?娌℃湁getPicture() 姝e父
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?

涓嶅姞fetch錛?join" 涓鍙ユ煡璇⒙?鏈塯etPicture() 姝e父
Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?

涓嶅姞fetch錛?join" 涓鍙ユ煡璇?鏈塯etPicture() 騫朵笖璁塊棶閲岄潰鐨勫厓绱燩icture鐨処D 鏈夊紓甯告姏鍑?br />Hibernate: select photos0_.id as id0_0_, photos0_.userid as userid0_0_, photos0_.typeid as typeid0_0_, photos0_.name as name0_0_, photos0_.createtime as createtime0_0_, photos0_.description as descript6_0_0_, photos0_.faceid as faceid0_0_, photos0_.uri as uri0_0_ from super.photos photos0_ where photos0_.id=?

鏉ヤ釜涓ゅ叺浜ゆ垬 fetch="join" lazy="true"聽(tīng) 鍛靛懙 緇撴灉錛屼竴鍙ユ煡璇紝 緇撴瀯姝e父 鎵浠ュ氨褰搇azy涓嶅瓨鍦ㄥソ浜?jiǎn)銆?鐪嬫潵fetch 鏄佸ぇ銆傘併併併併併併併併併併併併?br />Hibernate: select photos0_.id as id0_1_, photos0_.userid as userid0_1_, photos0_.typeid as typeid0_1_, photos0_.name as name0_1_, photos0_.createtime as createtime0_1_, photos0_.description as descript6_0_1_, photos0_.faceid as faceid0_1_, photos0_.uri as uri0_1_, pictures1_.photosid as photosid3_, pictures1_.id as id3_, pictures1_.id as id2_0_, pictures1_.photosid as photosid2_0_, pictures1_.name as name2_0_, pictures1_.clicked as clicked2_0_, pictures1_.uploaddate as uploaddate2_0_, pictures1_.size as size2_0_, pictures1_.description as descript7_2_0_, pictures1_.uri as uri2_0_ from super.photos photos0_ left outer join super.picture pictures1_ on photos0_.id=pictures1_.photosid where photos0_.id=?



pear 2006-11-05 20:04 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 上栗县| 乐至县| 石嘴山市| 双城市| 文登市| 乌拉特中旗| 景洪市| 九龙城区| 克山县| 济南市| 巴中市| 宝兴县| 军事| 木里| 尚义县| 唐海县| 灵武市| 太谷县| 津南区| 疏勒县| 天峻县| 乐山市| 重庆市| 兴仁县| 蓬溪县| 盱眙县| 青铜峡市| 昌宁县| 山东省| 敖汉旗| 彭泽县| 吉木乃县| 贵南县| 马鞍山市| 怀柔区| 郎溪县| 深圳市| 祁连县| 阳曲县| 怀仁县| 宁海县|