锘??xml version="1.0" encoding="utf-8" standalone="yes"?>99亚洲男女激情在线观看,亚洲色偷偷综合亚洲AV伊人,亚洲国产精品尤物YW在线观看 http://m.tkk7.com/liaojiyong/category/12345.htmlzh-cnThu, 29 Mar 2007 11:18:55 GMTThu, 29 Mar 2007 11:18:55 GMT60Hibernate O/R鏄犲皠涓夊ぇ鍩烘湰瀹氬垯(杞?http://m.tkk7.com/liaojiyong/archive/2007/03/29/107230.htmlliaojiyongliaojiyongThu, 29 Mar 2007 07:06:00 GMThttp://m.tkk7.com/liaojiyong/archive/2007/03/29/107230.htmlhttp://m.tkk7.com/liaojiyong/comments/107230.htmlhttp://m.tkk7.com/liaojiyong/archive/2007/03/29/107230.html#Feedback0http://m.tkk7.com/liaojiyong/comments/commentRss/107230.htmlhttp://m.tkk7.com/liaojiyong/services/trackbacks/107230.html鍦↗ava鐜涓嬶紝鏈夊縐嶅璞″叧緋繪槧灝勬柟娉曪紝濡傚疄浣揃ean銆丱JB銆丣DO銆丣DBC絳夈侶ibernate鏄竴縐嶆柊鐨凮/R鏄犲皠宸ュ叿錛屽畠涓嶄粎鎻愪緵浜嗕粠Java綾誨埌鏁版嵁琛ㄧ殑鏄犲皠錛屼篃鎻愪緵浜嗘暟鎹煡璇㈠拰鎭㈠絳夋満鍒躲侶ibernate闈炲父綆鍗曟槗瀛?鐩墠鍥藉唴鏈夊緢澶氬悓琛屽凡緇忔垨姝e湪鐢℉ibernate寮鍙戝疄鏂介」鐩?浣咹ibernate鏈夊緢澶氳鍒欎笉涓轟漢鐭ユ垨搴旂敤鐢氬皯銆傛湰鏂囩殑鐩殑灝辨槸灝嗚繖浜涜鍒欏綊綰蟲葷粨,甯屾湜瀵規(guī)偍鐨勫紑鍙戝拰璁捐鏈夌泭銆?br />
棣栧厛澹版槑,鏈枃鏄疕ibernate鍏ラ棬綰ф枃绔?楂樻墜璇蜂笉鐢ㄥ線涓嬬湅浜嗐?br />
2. 鍩烘湰瀹氬垯

瀹氬垯涓:鏁版嵁搴撻厤緗枃浠跺悕縐板彲浠ヤ笉鏄疕ibernate.properties鎴朒ibernate.cfg.xml

鐢變簬Hibernate瀹樻柟鏂囨。(鏈枃鎸噖ww.hibernate.org鐨勬枃妗?鐨勫獎鍝?寰堝Hibernate寮鍙戣呰浠ヤ負(fù)緋葷粺涓瀹氳鏈夊悕縐頒負(fù)Hibernate.properties鎴朒ibernate.cfg.xml鐨勬枃浠?鑰屼笖涓瀹氳鏀懼湪classes鐨勬牴鐩綍涓嬨傚疄闄呬笂,璇ユ枃浠跺彧鏄竴鑸殑閰嶇疆鏂囦歡,鍚嶇О鍙互鑷繁鍙?鏂囦歡浣嶇疆鍙互鑷繁瀹?鑰屼笖鍦ㄥ鏁版嵁搴撶幆澧冧笅,鍙互鏈夊涓厤緗枃浠?浣垮緱紼嬪簭鍙互榪炴帴澶氫釜鏁版嵁搴撱傚彧鏄?zhèn)ㄥ湪鍒涘晦Z細(xì)璇濆伐鍘傛椂闇瑕佺壒孌婂鐞?浠g爜紺轟緥濡備笅:

//閰嶇疆鏂囦歡鍚嶇О

protected static String CONFIG_FILE = "my_hibernate.config";

//閰嶇疆鏂囦歡鐩綍,鍙互鑰冭檻鍦ㄨ鐩綍涓嬪瓨鏀劇郴緇熸墍鏈夐厤緗枃浠?姝ゅ浣跨敤铏氭嫙鏈哄弬鏁?br />
String configPath = System.getProperty("my.config");

//鍒涘緩浼?xì)璇濆伐鍘?

sessionFactory =( new Configuration().configure(new File(configPath+File.separator+CONFIG_FILE))) .buildSessionFactory();



瀹氬垯浜?灝忓瀷欏圭洰涓?.hbm.xml鏂囦歡鍙互鍚堝茍鍒頒竴涓枃浠朵腑

鍚屾牱鐢變簬Hibernate瀹樻柟鏂囨。鐨勫獎鍝?寰堝Hibernate寮鍙戣呰浠ヤ負(fù)Hibernate鐨勫璞″叧緋繪槧灝勪竴瀹氳涓涓〃瀵瑰簲涓涓璞?騫跺皢鏄犲皠鏂囦歡鍜屽璞℃枃浠舵斁鍦ㄥ悓涓鐩綍涓嬨傚疄闄呬笂,璇ユā寮忔槸涓鴻鑼冩ц冭檻鑰岃璁$殑,鍥犱負(fù)鍦ㄥ浜哄弬涓庣殑欏圭洰涓?澶氫漢瑕佺淮鎶ゅ悓涓鏂囦歡瀹規(guī)槗浜х敓鍐茬獊;褰撻」鐩瘮杈冨皬鏃?閰嶇疆鏂囦歡鐨勭淮鎶や漢鍛樺皯,鎴戜滑瀹屽叏鍙互灝?hbm.xml鏂囦歡鍚堝茍鍒頒竴涓垨鑰呭嚑涓枃浠朵腑銆備緷鎹綔鑰呮湰浜虹殑欏圭洰璁捐寮鍙戠粡楠?鏈濂芥槸欏圭洰涓湁鍑犱漢鍚屾椂浠庝簨O/R鏄犲皠鍜屾寔涔呭伐浣?鍒欒瀹氬嚑涓?hbm.xml鏂囦歡,姣忎漢緇存姢涓涓傚綋鐒?涓轟簡渚夸簬鍒嗙被鍜岀鐞?姣忎漢鐨勫伐浣滃簲璇ユ寜閫昏緫鍒掑垎銆?br />
澶у瀷欏圭洰涓殑鏂囦歡閰嶇疆紺轟緥濡備笅:

<hibernate-configuration>

<session-factory>

<!鈥旀槧灝勬枃浠跺垎鏁?-->

<mapping resource="com/hongsoft/test/ persistence/Cat.hbm.xml"/>

<mapping resource="com/hongsoft/test/ persistence/Animal.hbm.xml"/>

</session-factory>

</hibernate-configuration>

灝忓瀷欏圭洰涓殑鏂囦歡閰嶇疆紺轟緥濡備笅:

<hibernate-configuration>

<session-factory>

<!鈥旀槧灝勬枃浠墮泦涓?-->

<mapping resource="res_hibernate_map.xml"/>

</session-factory>

</hibernate-configuration>

瑕佹敞鎰忕殑鏄? 浠庡Hibernate婧愪唬鐮佺殑鍒嗘瀽鍙煡,鎸囧畾鏄犲皠鏂囦歡鏃?涓嶈兘鐢ㄧ粷瀵圭洰褰?鍙兘鐢ㄧ浉瀵圭洰褰?鑰屼笖,緋葷粺浠lasses鏍圭洰褰曚負(fù)褰撳墠鐩綍銆?br />


瀹氬垯涓?瀵硅薄鍏崇郴鏄犲皠鏄互.hbm.xml鏂囦歡涓哄熀鍑嗙殑,鑰屼笉鏄互PO鏂囦歡涓哄熀鍑?br />
璇ュ畾寰嬬殑鎰忔濇槸:緋葷粺鍚姩媯鏌ユ?zhèn)ㄧ殑瀵硅薄鍏尘p繪槧灝勬槸鍚︽紜椂,鏄互.hbm.xml涓哄熀鍑嗘潵榪涜媯鏌ョ殑;瀵硅薄鏂囦歡鐨刾roperty鍙互姣旀槧灝勬枃浠剁殑property澶?浣嗕笉鑳藉皯銆傚鏋滄?zhèn)ㄦ湁濡備笅鐨勬槧灏?

<class name="com.hongsoft.test.User" table="res_user">

<id name="id" column="id" type="long" unsaved-value="any">

<generator class="assigned">

</generator>

</id>

<property name="name"/>

<property name="loginName"/>

<property name="passwd"/>

</class>

緋葷粺鍚姩,媯鏌ユ暟鎹簱鍜屽叾浠栭厤緗紜悗,灝嗕互璇ユ枃浠朵負(fù)鍩哄噯,棣栧厛媯鏌ser瀵硅薄涓湁鏃爄d灞炴у拰瀵瑰簲鐨刧et/set鏂規(guī)硶,濡傛灉娌℃湁鍒欐姤閿?濡傛灉鏈変笖姝g‘鍒欐鏌ユ湁鏃爊ame灞炴у拰瀵瑰簲鐨刧et/set鏂規(guī)硶鈥︹?鐩村埌鏂囦歡緇撴潫銆傝娉ㄦ剰鐨勬槸,濡傛灉灞炴т負(fù)name,鍒檊et鏂規(guī)硶鍚嶇О蹇呴』涓篻etName(),set鏂規(guī)硶鍚嶇О蹇呴』涓簊etName(),鍚﹀垯浼?xì)鎶ラ敊銆?br />
濡傛灉User瀵硅薄闄や簡鏈塱d,name,loginName, passwd鍥涗釜灞炴у拰瀵瑰簲鐨勬柟娉?榪樻湁鍏跺畠鐨勫睘鎬у拰鏂規(guī)硶,浼?xì)鎶ラ敊鍚?涓嶄細(xì),鍥犱負(fù)瀵硅薄鍏崇郴鏄犲皠鏄互.hbm.xml鏂囦歡涓哄熀鍑嗙殑,鑰屼笉鏄互PO鏂囦歡涓哄熀鍑嗐傛?zhèn)ㄥ湪椤圭洰涓彲浠ュ厖鍒嗗埄鐢ㄨ鐗圭?瀹炵幇鎮(zhèn)ㄨ嚜宸辯殑姣旇緝鐗規(guī)畩鐨勯渶姹傘備緥濡?鎮(zhèn)ㄥ彲浠ュ湪User瀵硅薄涓姞鍏pdatedPasswd琛ㄧず鏇存敼鍚庣殑鍙d護(hù),鐢辨鏋勯犲湪琛ㄧず灞傝浣跨敤鐨凢ormBean鍜屽湪涓氬姟灞傝浣跨敤鐨刅alueObject銆傚綋鐒?榪欐牱鍋氫篃鏈夌己鐐?闇瑕佹牴鎹?zhèn)ㄧ殑瀹為檯鎯呭喌鑰屽畾銆?br />
3. 鎬葷粨
涓婇潰鏄綔鑰呭Hibernate鏄犲皠鐨勫鏄撶悊瑙i敊璇殑鐭ヨ瘑鐐圭殑褰掔撼鎬葷粨,甯屾湜瀵規(guī)偍鏈夊府鍔┿傚鏋滄?zhèn)ㄥ彂鐜版湁閿欒鎴栨湁鑷忿q殑瑙傜偣,嬈㈣繋璁ㄨ銆?br />

]]>
Hibernate紼嬪簭鎬ц兘浼樺寲鐨勮冭檻瑕佺偣(杞? http://m.tkk7.com/liaojiyong/archive/2007/03/23/105725.htmlliaojiyongliaojiyongFri, 23 Mar 2007 01:48:00 GMThttp://m.tkk7.com/liaojiyong/archive/2007/03/23/105725.htmlhttp://m.tkk7.com/liaojiyong/comments/105725.htmlhttp://m.tkk7.com/liaojiyong/archive/2007/03/23/105725.html#Feedback0http://m.tkk7.com/liaojiyong/comments/commentRss/105725.htmlhttp://m.tkk7.com/liaojiyong/services/trackbacks/105725.html銆銆鍒濈敤HIBERNATE鐨勪漢涔熻閮介亣鍒拌繃鎬ц兘闂錛屽疄鐜板悓涓鍔熻兘錛岀敤HIBERNATE涓庣敤JDBC鎬ц兘鐩稿樊鍗佸嚑鍊嶅緢姝e父錛屽鏋滀笉鍙婃棭璋冩暣錛屽緢鍙兘褰卞搷鏁翠釜欏圭洰鐨勮繘搴︺?/p>

銆銆澶т綋涓婏紝瀵逛簬HIBERNATE鎬ц兘璋冧紭鐨勪富瑕佽冭檻鐐瑰涓?

銆銆脴 鏁版嵁搴撹璁¤皟鏁?/p>

銆銆脴 HQL浼樺寲

銆銆脴 API鐨勬紜嬌鐢?濡傛牴鎹笉鍚岀殑涓氬姟綾誨瀷閫夌敤涓嶅悓鐨勯泦鍚堝強鏌ヨAPI)

銆銆脴 涓婚厤緗弬鏁?鏃ュ織錛屾煡璇㈢紦瀛橈紝fetch_size, batch_size絳?

銆銆脴 鏄犲皠鏂囦歡浼樺寲(ID鐢熸垚絳栫暐錛屼簩綰х紦瀛橈紝寤惰繜鍔犺澆錛屽叧鑱斾紭鍖?

銆銆脴 涓綰х紦瀛樼殑綆$悊

銆銆脴 閽堝浜岀駭緙撳瓨錛岃繕鏈夎澶氱壒鏈夌殑絳栫暐

銆銆脴 浜嬪姟鎺у埗絳栫暐銆?/p>

銆銆1銆?鏁版嵁搴撹璁?/p>

銆銆a) 闄嶄綆鍏寵仈鐨勫鏉傛?/p>

銆銆b) 灝介噺涓嶄嬌鐢ㄨ仈鍚堜富閿?/p>

銆銆c) ID鐨勭敓鎴愭満鍒訛紝涓嶅悓鐨勬暟鎹簱鎵鎻愪緵鐨勬満鍒跺茍涓嶅畬鍏ㄤ竴鏍?/p>

銆銆d) 閫傚綋鐨勫啑浣欐暟鎹紝涓嶈繃鍒嗚拷姹傞珮鑼冨紡

銆銆2銆?HQL浼樺寲

銆銆HQL濡傛灉鎶涘紑瀹冨悓HIBERNATE鏈韓涓浜涚紦瀛樻満鍒剁殑鍏寵仈錛孒QL鐨勪紭鍖栨妧宸у悓鏅氱殑SQL浼樺寲鎶宸т竴鏍鳳紝鍙互寰堝鏄撳湪緗戜笂鎵懼埌涓浜涚粡楠屼箣璋堛?/p>

銆銆3銆?涓婚厤緗?/p>

銆銆a) 鏌ヨ緙撳瓨錛屽悓涓嬮潰璁茬殑緙撳瓨涓嶅お涓鏍鳳紝瀹冩槸閽堝HQL璇彞鐨勭紦瀛橈紝鍗沖畬鍏ㄤ竴鏍風(fēng)殑璇彞鍐嶆鎵ц鏃跺彲浠ュ埄鐢ㄧ紦瀛樻暟鎹備絾鏄紝鏌ヨ緙撳瓨鍦ㄤ竴涓氦鏄撶郴緇?鏁版嵁鍙樻洿棰戠箒錛屾煡璇㈡潯浠剁浉鍚岀殑鏈虹巼騫朵笉澶?涓彲鑳戒細(xì)璧峰弽浣滅敤:瀹冧細(xì)鐧界櫧鑰楄垂澶ч噺鐨勭郴緇熻祫婧愪絾鍗撮毦浠ユ淳涓婄敤鍦恒?/p>

銆銆b) fetch_size錛屽悓JDBC鐨勭浉鍏沖弬鏁頒綔鐢ㄧ被浼鹼紝鍙傛暟騫朵笉鏄秺澶ц秺濂斤紝鑰屽簲鏍規(guī)嵁涓氬姟鐗瑰緛鍘昏緗?/p>

銆銆c) batch_size鍚屼笂銆?/p>

銆銆d) 鐢熶駭緋葷粺涓紝鍒囪瑕佸叧鎺塖QL璇彞鎵撳嵃銆?/p>

銆銆4銆?緙撳瓨

銆銆a) 鏁版嵁搴撶駭緙撳瓨:榪欑駭緙撳瓨鏄渶楂樻晥鍜屽畨鍏ㄧ殑錛屼絾涓嶅悓鐨勬暟鎹簱鍙鐞嗙殑灞傛騫朵笉涓鏍鳳紝姣斿錛屽湪ORACLE涓紝鍙互鍦ㄥ緩琛ㄦ椂鎸囧畾灝嗘暣涓〃緗簬緙撳瓨褰撲腑銆?/p>

銆銆b) SESSION緙撳瓨:鍦ㄤ竴涓狧IBERNATE SESSION鏈夋晥錛岃繖綰х紦瀛樼殑鍙共棰勬т笉寮猴紝澶у浜嶩IBERNATE鑷姩綆$悊錛屼絾瀹冩彁渚涙竻闄ょ紦瀛樼殑鏂規(guī)硶錛岃繖鍦ㄥぇ鎵歸噺澧炲姞/鏇存柊鎿嶄綔鏄湁鏁堢殑銆傛瘮濡傦紝鍚屾椂澧炲姞鍗佷竾鏉¤褰曪紝鎸夊父瑙勬柟寮忚繘琛岋紝寰堝彲鑳戒細(xì)鍙戠幇OutofMemeroy鐨勫紓甯革紝榪欐椂鍙兘闇瑕佹墜鍔ㄦ竻闄よ繖涓綰х紦瀛?Session.evict浠ュ強Session.clear

銆銆c) 搴旂敤緙撳瓨:鍦ㄤ竴涓猄ESSIONFACTORY涓湁鏁堬紝鍥犳涔熸槸浼樺寲鐨勯噸涓箣閲嶏紝鍥犳錛屽悇綾葷瓥鐣ヤ篃鑰冭檻鐨勮緝澶氾紝鍦ㄥ皢鏁版嵁鏀懼叆榪欎竴綰х紦瀛樹箣鍓嶏紝闇瑕佽冭檻涓浜涘墠鎻愭潯浠?

銆銆i. 鏁版嵁涓嶄細(xì)琚涓夋柟淇敼(姣斿錛屾槸鍚︽湁鍙︿竴涓簲鐢ㄤ篃鍦ㄤ慨鏀硅繖浜涙暟鎹?)

銆銆ii. 鏁版嵁涓嶄細(xì)澶ぇ

銆銆iii. 鏁版嵁涓嶄細(xì)棰戠箒鏇存柊(鍚﹀垯浣跨敤CACHE鍙兘閫傚緱鍏跺弽)

銆銆iv. 鏁版嵁浼?xì)琚绻佹煡璇?/p>

銆銆v. 鏁版嵁涓嶆槸鍏抽敭鏁版嵁(濡傛秹鍙婇挶錛屽畨鍏ㄧ瓑鏂歸潰鐨勯棶棰?銆?/p>

銆銆緙撳瓨鏈夊嚑縐嶅艦寮忥紝鍙互鍦ㄦ槧灝勬枃浠朵腑閰嶇疆:read-only(鍙錛岄傜敤浜庡緢灝戝彉鏇寸殑闈欐佹暟鎹?鍘嗗彶鏁版嵁)錛宯onstrict-read-write錛宺ead-write(姣旇緝鏅亶鐨勫艦寮忥紝鏁堢巼涓鑸?錛宼ransactional(JTA涓紝涓旀敮鎸佺殑緙撳瓨浜у搧杈冨皯)

銆銆d) 鍒嗗竷寮忕紦瀛?鍚宑)鐨勯厤緗竴鏍鳳紝鍙槸緙撳瓨浜у搧鐨勯夌敤涓嶅悓錛屽湪鐩墠鐨凥IBERNATE涓彲渚涢夋嫨鐨勪笉澶氾紝oscache, jboss cache錛岀洰鍓嶇殑澶у鏁伴」鐩紝瀵瑰畠浠殑鐢ㄤ簬闆嗙兢鐨勪嬌鐢?鐗瑰埆鏄叧閿氦鏄撶郴緇?閮芥寔淇濆畧鎬佸害銆傚湪闆嗙兢鐜涓紝鍙埄鐢ㄦ暟鎹簱綰х殑緙撳瓨鏄渶瀹夊叏鐨勩?/p>

銆銆5銆?寤惰繜鍔犺澆

銆銆a) 瀹炰綋寤惰繜鍔犺澆:閫氳繃浣跨敤鍔ㄦ佷唬鐞嗗疄鐜?/p>

銆銆b) 闆嗗悎寤惰繜鍔犺澆:閫氳繃瀹炵幇鑷湁鐨凷ET/LIST錛孒IBERNATE鎻愪緵浜嗚繖鏂歸潰鐨勬敮鎸?/p>

銆銆c) 灞炴у歡榪熷姞杞?

銆銆6銆?鏂規(guī)硶閫夌敤

銆銆a) 瀹屾垚鍚屾牱涓浠朵簨錛孒IBERNATE鎻愪緵浜嗗彲渚涢夋嫨鐨勪竴浜涙柟寮忥紝浣嗗叿浣撲嬌鐢ㄤ粈涔堟柟寮忥紝鍙兘鐢ㄦц兘/浠g爜閮戒細(xì)鏈夊獎鍝嶃傛樉紺猴紝涓嬈¤繑鍥炲崄涓囨潯璁板綍(List/Set/Bag/Map絳?榪涜澶勭悊錛屽緢鍙兘瀵艱嚧鍐呭瓨涓嶅鐨勯棶棰橈紝鑰屽鏋滅敤鍩轟簬娓告爣(ScrollableResults)鎴朓terator鐨勭粨鏋滈泦錛屽垯涓嶅瓨鍦ㄨ繖鏍風(fēng)殑闂銆?/p>

銆銆b) Session鐨刲oad/get鏂規(guī)硶錛屽墠鑰呬細(xì)浣跨敤浜岀駭緙撳瓨錛岃屽悗鑰呭垯涓嶄嬌鐢ㄣ?/p>

銆銆c) Query鍜宭ist/iterator錛屽鏋滃幓浠旂粏鐮旂┒涓涓嬪畠浠紝浣犲彲鑳戒細(xì)鍙戠幇寰堝鏈夋剰鎬濈殑鎯呭喌錛屼簩鑰呬富瑕佸尯鍒?濡傛灉浣跨敤浜哠pring錛屽湪HibernateTemplate涓搴攆ind,iterator鏂規(guī)硶):

銆銆i. list鍙兘鍒╃敤鏌ヨ緙撳瓨(浣嗗湪浜ゆ槗緋葷粺涓煡璇㈢紦瀛樹綔鐢ㄤ笉澶?錛屾棤娉曞埄鐢ㄤ簩綰х紦瀛樹腑鐨勫崟涓疄浣擄紝浣唋ist鏌ュ嚭鐨勫璞′細(xì)鍐欏叆浜岀駭緙撳瓨錛屼絾瀹冧竴鑸彧鐢熸垚杈冨皯鐨勬墽琛孲QL璇彞錛屽緢澶氭儏鍐靛氨鏄竴鏉?鏃犲叧鑱?銆?/p>

銆銆ii. iterator鍒欏彲浠ュ埄鐢ㄤ簩綰х紦瀛橈紝瀵逛簬涓鏉℃煡璇㈣鍙ワ紝瀹冧細(xì)鍏堜粠鏁版嵁搴撲腑鎵懼嚭鎵鏈夌鍚堟潯浠剁殑璁板綍鐨処D錛屽啀閫氳繃ID鍘葷紦瀛樻壘錛屽浜庣紦瀛樹腑娌℃湁鐨勮褰曪紝鍐嶆瀯閫犺鍙ヤ粠鏁版嵁搴撲腑鏌ュ嚭錛屽洜姝ゅ緢瀹規(guī)槗鐭ラ亾錛屽鏋滅紦瀛樹腑娌℃湁浠諱綍絎﹀悎鏉′歡鐨勮褰曪紝浣跨敤iterator浼?xì)漶旂敓N+1鏉QL璇彞(N涓虹鍚堟潯浠剁殑璁板綍鏁?

銆銆iii. 閫氳繃iterator錛岄厤鍚堢紦瀛樼鐞咥PI錛屽湪嫻烽噺鏁版嵁鏌ヨ涓彲浠ュ緢濂界殑瑙e喅鍐呭瓨闂錛屽:

銆銆while(it.hasNext()){

銆銆YouObject object = (YouObject)it.next();

銆銆session.evict(youObject);

銆銆sessionFactory.evice(YouObject.class, youObject.getId());

銆銆}

銆銆濡傛灉鐢╨ist鏂規(guī)硶錛屽緢鍙兘灝卞嚭OutofMemory閿欒浜嗐?/p>

銆銆iv. 閫氳繃涓婇潰鐨勮鏄庯紝鎴戞兂浣犲簲璇ョ煡閬撳浣曞幓浣跨敤榪欎袱涓柟娉曚簡銆?/p>

銆銆7銆?闆嗗悎鐨勯夌敤

銆銆鍦℉IBERNATE 3.1鏂囨。鐨勨?9.5. Understanding Collection performance鈥濅腑鏈夎緇嗙殑璇存槑銆?/p>

銆銆8銆?浜嬪姟鎺у埗

銆銆浜嬪姟鏂歸潰瀵規(guī)ц兘鏈夊獎鍝嶇殑涓昏鍖呮嫭:浜嬪姟鏂瑰紡鐨勯夌敤錛屼簨鍔¢殧紱葷駭鍒互鍙婇攣鐨勯夌敤

銆銆a) 浜嬪姟鏂瑰紡閫夌敤:濡傛灉涓嶆秹鍙婂涓簨鍔$鐞嗗櫒浜嬪姟鐨勮瘽錛屼笉闇瑕佷嬌鐢↗TA錛屽彧鏈塉DBC鐨勪簨鍔℃帶鍒跺氨鍙互銆?/p>

銆銆b) 浜嬪姟闅旂綰у埆:鍙傝鏍囧噯鐨凷QL浜嬪姟闅旂綰у埆

銆銆c) 閿佺殑閫夌敤:鎮(zhèn)茶閿?涓鑸敱鍏蜂綋鐨勪簨鍔$鐞嗗櫒瀹炵幇)錛屽浜庨暱浜嬪姟鏁堢巼浣庯紝浣嗗畨鍏ㄣ備箰瑙傞攣(涓鑸湪搴旂敤綰у埆瀹炵幇)錛屽鍦℉IBERNATE涓彲浠ュ畾涔塚ERSION瀛楁錛屾樉鐒訛紝濡傛灉鏈夊涓簲鐢ㄦ搷浣滄暟鎹紝涓旇繖浜涘簲鐢ㄤ笉鏄敤鍚屼竴縐嶄箰瑙傞攣鏈哄埗錛屽垯涔愯閿佷細(xì)澶辨晥銆傚洜姝わ紝閽堝涓嶅悓鐨勬暟鎹簲鏈変笉鍚岀殑絳栫暐錛屽悓鍓嶉潰璁稿鎯呭喌涓鏍鳳紝寰堝鏃跺欐垜浠槸鍦ㄦ晥鐜囦笌瀹夊叏/鍑嗙‘鎬т笂鎵句竴涓鉤琛$偣錛屾棤璁哄浣曪紝浼樺寲閮戒笉鏄竴涓函鎶鏈殑闂錛屼綘搴旇瀵逛綘鐨勫簲鐢ㄥ拰涓氬姟鐗瑰緛鏈夎凍澶熺殑浜嗚В銆?/p>

銆銆9銆?鎵歸噺鎿嶄綔

銆銆鍗充嬌鏄嬌鐢↗DBC錛屽湪榪涜澶ф壒鏁版嵁鏇存柊鏃訛紝BATCH涓庝笉浣跨敤BATCH鏈夋晥鐜囦笂涔熸湁寰堝ぇ鐨勫樊鍒傛垜浠彲浠ラ氳繃璁劇疆batch_size鏉ヨ鍏舵敮鎸佹壒閲忔搷浣溿?/p>

銆銆涓句釜渚嬪瓙錛岃鎵歸噺鍒犻櫎鏌愯〃涓殑瀵硅薄錛屽鈥渄elete Account鈥濓紝鎵撳嚭鏉ョ殑璇彞錛屼細(xì)鍙戠幇HIBERNATE鎵懼嚭浜嗘墍鏈堿CCOUNT鐨処D錛屽啀榪涜鍒犻櫎錛岃繖涓昏鏄負(fù)浜嗙淮鎶や簩綰х紦瀛橈紝榪欐牱鏁堢巼鑲畾楂樹笉浜嗭紝鍦ㄥ悗緇殑鐗堟湰涓鍔犱簡bulk delete/update錛屼絾榪欎篃鏃犳硶瑙e喅緙撳瓨鐨勭淮鎶ら棶棰樸備篃灝辨槸璇達(dá)紝鐢變簬鏈変簡浜岀駭緙撳瓨鐨勭淮鎶ら棶棰橈紝HIBERNATE鐨勬壒閲忔搷浣滄晥鐜囧茍涓嶅敖濡備漢鎰?

銆銆浠庡墠闈㈣澶氳鐐瑰彲浠ョ湅鍑猴紝寰堝鏃跺欐垜浠槸鍦ㄦ晥鐜囦笌瀹夊叏/鍑嗙‘鎬т笂鎵句竴涓鉤琛$偣錛屾棤璁哄浣曪紝浼樺寲閮戒笉鏄竴涓函鎶鏈殑闂錛屼綘搴旇瀵逛綘鐨勫簲鐢ㄥ拰涓氬姟鐗瑰緛鏈夎凍澶熺殑浜嗚В錛屼竴鑸殑錛屼紭鍖栨柟妗堝簲鍦ㄦ灦鏋勮璁℃湡灝卞熀鏈‘瀹氾紝鍚﹀垯鍙兘瀵艱嚧娌″繀瑕佺殑榪斿伐錛岃嚧浣塊」鐩歡鏈燂紝鑰屼綔涓烘灦鏋勫笀鍜岄」鐩粡鐞嗭紝榪樿闈㈠寮鍙戜漢鍛樺彲鑳界殑鎶辨紝蹇呯珶錛屾垜浠鐢ㄦ埛闇姹傛洿鏀圭殑鎺у埗鍔涗笉澶э紝浣嗘妧鏈?鏋舵瀯椋庨櫓鏄簲璇ュ湪鍒濇湡鎰忚瘑鍒板茍鍒跺畾濂界浉鍏崇殑瀵圭瓥銆?/p>

銆銆榪樻湁涓鐐硅娉ㄦ剰錛屽簲鐢ㄥ眰鐨勭紦瀛樺彧鏄敠涓婃坊鑺憋紝姘歌繙涓嶈鎶婂畠褰撴晳鍛界ɑ鑽夛紝搴旂敤鐨勬牴鍩?鏁版嵁搴撹璁★紝綆楁硶錛岄珮鏁堢殑鎿嶄綔璇彞錛屾伆褰揂PI鐨勯夋嫨絳?鎵嶆槸鏈閲嶈鐨勩?/p>

]]>
Hibernate澶ф暟鎹噺鎿嶄綔瑙e喅鏂規(guī)錛堣綁錛?/title><link>http://m.tkk7.com/liaojiyong/archive/2007/01/12/93454.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Fri, 12 Jan 2007 07:30:00 GMT</pubDate><guid>http://m.tkk7.com/liaojiyong/archive/2007/01/12/93454.html</guid><wfw:comment>http://m.tkk7.com/liaojiyong/comments/93454.html</wfw:comment><comments>http://m.tkk7.com/liaojiyong/archive/2007/01/12/93454.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/liaojiyong/comments/commentRss/93454.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/liaojiyong/services/trackbacks/93454.html</trackback:ping><description><![CDATA[ <div id="8mm2aws" class="postTitle"> <font size="4">闃呰浜咹ibernate鐨凴eference涔嬪悗錛屽彲浠ラ噰鐢ㄦ壒閲忓鐞嗙殑鏂規(guī)硶錛屽綋鎻掑叆鐨勬暟鎹秴榪?0000鏃訛紝灝眆lush session騫朵笖clear銆?/font> </div> <div align="left"> <font size="4">涓嬮潰鏄竴涓祴璇昺ethod銆?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">聽1</span><img id="Codehighlighter1_0_96_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_96_Open_Text.style.display='none'; Codehighlighter1_0_96_Closed_Image.style.display='inline'; Codehighlighter1_0_96_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_0_96_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_96_Closed_Text.style.display='none'; Codehighlighter1_0_96_Open_Image.style.display='inline'; Codehighlighter1_0_96_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span>/**聽*/<span>/**<br /></span><span>聽2<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽*聽嫻嬭瘯鎴愭壒鎻掑叆鏁版嵁鐨勪簨鍔″鐞嗭紝榪斿洖鏄惁鎴愬姛<br />聽3<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽*聽<br /></span><span style="COLOR: #008080">聽4</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽*聽@param聽objPO聽Object<br /></span><span style="COLOR: #008080">聽5</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽*聽@return聽boolean<br /></span><span style="COLOR: #008080">聽6</span><span style="COLOR: #008000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />聽聽聽聽聽</span><span style="COLOR: #008000">*/</span></span><span><br />聽7<img id="Codehighlighter1_149_1523_Open_Image" onclick="this.style.display='none'; Codehighlighter1_149_1523_Open_Text.style.display='none'; Codehighlighter1_149_1523_Closed_Image.style.display='inline'; Codehighlighter1_149_1523_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_149_1523_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_149_1523_Closed_Text.style.display='none'; Codehighlighter1_149_1523_Open_Image.style.display='inline'; Codehighlighter1_149_1523_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />聽聽聽聽</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000">聽insertBatch(</span><span style="COLOR: #0000ff">final</span><span>聽Object聽objPO)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">聽8</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000">聽isSuccess聽</span><span style="COLOR: #000000">=</span><span>聽false;<br /></span><span style="COLOR: #008080">聽9</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽Transaction聽transaction聽</span><span style="COLOR: #000000">=</span><span>聽null;<br /></span><span style="COLOR: #008080">10</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽Session聽session聽=聽openSession();<br /></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img id="Codehighlighter1_279_802_Open_Image" onclick="this.style.display='none'; Codehighlighter1_279_802_Open_Text.style.display='none'; Codehighlighter1_279_802_Closed_Image.style.display='inline'; Codehighlighter1_279_802_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_279_802_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_279_802_Closed_Text.style.display='none'; Codehighlighter1_279_802_Open_Image.style.display='inline'; Codehighlighter1_279_802_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">try</span><span>聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">12</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽transaction聽=聽session.beginTransaction();<br /></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img id="Codehighlighter1_380_625_Open_Image" onclick="this.style.display='none'; Codehighlighter1_380_625_Open_Text.style.display='none'; Codehighlighter1_380_625_Closed_Image.style.display='inline'; Codehighlighter1_380_625_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_380_625_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_380_625_Closed_Text.style.display='none'; Codehighlighter1_380_625_Open_Image.style.display='inline'; Codehighlighter1_380_625_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">聽(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽i聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;聽i聽</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">100000</span><span style="COLOR: #000000">;聽i</span><span style="COLOR: #000000">++</span><span>)聽<img src="http://m.tkk7.com/images/dot.gif" /><span>{<br />14<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽session.save(objPO);<br /></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img id="Codehighlighter1_452_611_Open_Image" onclick="this.style.display='none'; Codehighlighter1_452_611_Open_Text.style.display='none'; Codehighlighter1_452_611_Closed_Image.style.display='inline'; Codehighlighter1_452_611_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_452_611_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_452_611_Closed_Text.style.display='none'; Codehighlighter1_452_611_Open_Image.style.display='inline'; Codehighlighter1_452_611_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">聽(i聽</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">50</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">0</span><span>)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span>//聽flush聽a聽batch聽of聽inserts聽and聽release聽memory<br />17</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽session.flush();<br />18<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽session.clear();<br /></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span></span><span><br />20</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽}</span></span><span><br />21<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽transaction.commit();<br /></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽logger.info(</span><span style="COLOR: #000000">"</span><span>transaction.wasCommitted:"<br />23</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽+聽transaction.wasCommitted());<br /></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽isSuccess聽</span><span style="COLOR: #000000">=</span><span>聽true;<br /></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img id="Codehighlighter1_834_1353_Open_Image" onclick="this.style.display='none'; Codehighlighter1_834_1353_Open_Text.style.display='none'; Codehighlighter1_834_1353_Closed_Image.style.display='inline'; Codehighlighter1_834_1353_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_834_1353_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_834_1353_Closed_Text.style.display='none'; Codehighlighter1_834_1353_Open_Image.style.display='inline'; Codehighlighter1_834_1353_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽}</span>聽catch</span><span>聽(HibernateException聽ex)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img id="Codehighlighter1_873_1239_Open_Image" onclick="this.style.display='none'; Codehighlighter1_873_1239_Open_Text.style.display='none'; Codehighlighter1_873_1239_Closed_Image.style.display='inline'; Codehighlighter1_873_1239_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_873_1239_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_873_1239_Closed_Text.style.display='none'; Codehighlighter1_873_1239_Open_Image.style.display='inline'; Codehighlighter1_873_1239_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">聽(transaction聽</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">null</span><span>)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img id="Codehighlighter1_895_1079_Open_Image" onclick="this.style.display='none'; Codehighlighter1_895_1079_Open_Text.style.display='none'; Codehighlighter1_895_1079_Closed_Image.style.display='inline'; Codehighlighter1_895_1079_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_895_1079_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_895_1079_Closed_Text.style.display='none'; Codehighlighter1_895_1079_Open_Image.style.display='inline'; Codehighlighter1_895_1079_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">try</span><span>聽<img src="http://m.tkk7.com/images/dot.gif" /><span>{<br />28<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽transaction.rollback();<br /></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽logger.error(</span><span style="COLOR: #000000">"</span><span>transaction.wasRolledBack:"<br />30</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽+聽transaction.wasRolledBack());<br /></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img id="Codehighlighter1_1112_1225_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1112_1225_Open_Text.style.display='none'; Codehighlighter1_1112_1225_Closed_Image.style.display='inline'; Codehighlighter1_1112_1225_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1112_1225_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1112_1225_Closed_Text.style.display='none'; Codehighlighter1_1112_1225_Open_Image.style.display='inline'; Codehighlighter1_1112_1225_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span>聽catch</span><span>聽(HibernateException聽ex1)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span>32<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽logger.error(ex1.getMessage());<br />33<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ex1.printStackTrace();<br /></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span></span><span><br />35</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽}</span></span><span><br />36<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽logger.error(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Insert聽Batch聽PO聽Error:</span><span style="COLOR: #000000">"</span><span>聽+聽ex.getMessage());<br />37<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽ex.printStackTrace();<br /></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img id="Codehighlighter1_1363_1491_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1363_1491_Open_Text.style.display='none'; Codehighlighter1_1363_1491_Closed_Image.style.display='inline'; Codehighlighter1_1363_1491_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1363_1491_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1363_1491_Closed_Text.style.display='none'; Codehighlighter1_1363_1491_Open_Image.style.display='inline'; Codehighlighter1_1363_1491_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽}</span>聽finally</span><span>聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img id="Codehighlighter1_1402_1452_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1402_1452_Open_Text.style.display='none'; Codehighlighter1_1402_1452_Closed_Image.style.display='inline'; Codehighlighter1_1402_1452_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1402_1452_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1402_1452_Closed_Text.style.display='none'; Codehighlighter1_1402_1452_Open_Image.style.display='inline'; Codehighlighter1_1402_1452_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">聽(transaction聽</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">null</span><span>)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽transaction聽</span><span style="COLOR: #000000">=</span><span>聽null;<br /></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽}</span></span><span><br />42<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽session.close();<br /></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽}</span></span><span><br />44</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽return聽isSuccess;<br /></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />聽聽聽聽}</span></span><span><br />46</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span></div><br />榪欏彧鏄畝鍗曠殑嫻嬭瘯錛屽疄闄呴」鐩腑閬囧埌鐨勯棶棰橈紝瑕佹瘮榪欎釜澶嶆潅寰楀銆?br />榪欐椂鍊欙紝鎴戜滑鍙互璁㏒pring鏉ユ帶鍒禩ransaction錛岃嚜宸辨潵鎺у埗Hibernate鐨凷ession錛岄殢鏃舵洿鏂版暟鎹?/font> <font size="2"> <br />棣栧厛錛屽埄鐢℉ibernateDaoSupport綾繪潵鑷畾涔変釜鏂規(guī)硶鎵撳紑Session錛?br /></font> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #008080">1</span> <img id="Codehighlighter1_28_125_Open_Image" onclick="this.style.display='none'; Codehighlighter1_28_125_Open_Text.style.display='none'; Codehighlighter1_28_125_Closed_Image.style.display='inline'; Codehighlighter1_28_125_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="Codehighlighter1_28_125_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_28_125_Closed_Text.style.display='none'; Codehighlighter1_28_125_Open_Image.style.display='inline'; Codehighlighter1_28_125_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /> <span style="COLOR: #0000ff">public</span> <span>聽Session聽openSession()<img src="http://m.tkk7.com/images/dot.gif" /><span>{<br />2<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /></span><span style="COLOR: #008080">3</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽return聽getHibernateTemplate().getSessionFactory().openSession();<br />4<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /></span><span style="COLOR: #008080">5</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />聽聽聽聽}</span></span> </div>鐒跺悗錛岀敤鎵撳紑鐨凷ession澶勭悊浣犵殑鏁版嵁錛?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">聽1</span><img id="Codehighlighter1_43_282_Open_Image" onclick="this.style.display='none'; Codehighlighter1_43_282_Open_Text.style.display='none'; Codehighlighter1_43_282_Closed_Image.style.display='inline'; Codehighlighter1_43_282_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_43_282_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_43_282_Closed_Text.style.display='none'; Codehighlighter1_43_282_Open_Image.style.display='inline'; Codehighlighter1_43_282_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">void</span><span>聽doBusiness(Session聽session)聽<img src="http://m.tkk7.com/images/dot.gif" /><span>{<br />聽2<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /></span><span style="COLOR: #008080">聽3</span><span style="COLOR: #000000"><img id="Codehighlighter1_67_273_Open_Image" onclick="this.style.display='none'; Codehighlighter1_67_273_Open_Text.style.display='none'; Codehighlighter1_67_273_Closed_Image.style.display='inline'; Codehighlighter1_67_273_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_67_273_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_67_273_Closed_Text.style.display='none'; Codehighlighter1_67_273_Open_Image.style.display='inline'; Codehighlighter1_67_273_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">聽(</span><span style="COLOR: #0000ff">true</span><span>)聽<img src="http://m.tkk7.com/images/dot.gif" /><span style="COLOR: #000000">{<br /></span><span style="COLOR: #008080">聽4</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span><span>//do聽your聽business聽with聽the聽opening聽session聽聽聽聽聽聽聽聽<br />聽5</span><span><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽someMethod(session);<br /></span><span>聽6<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽session.flush();<br />聽7<img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽session.clear();<br /></span><span style="COLOR: #008080">聽8</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽logger.info(</span><span style="COLOR: #000000">"</span><span>good聽job!");聽聽聽聽聽聽聽聽聽聽聽聽<br /></span><span style="COLOR: #008080">聽9</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽}</span>聽聽聽聽聽聽聽<br />10</span><span style="COLOR: #000000"><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div></div> <p>姣忓仛涓嬈℃暟鎹搷浣滐紝灝辨洿鏂頒竴嬈ession錛岃繖鏍峰彲浠ヤ繚璇佹瘡嬈℃暟鎹搷浣滈兘鎴愬姛錛屽惁鍒欏氨璁㏒pring鍘繪帶鍒跺畠roll back鍚с?br /><br />鏈鍚庯紝璁板緱鍏抽棴Session銆?br /></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #008080">1</span> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">Session聽session聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽openSession();<br /></span> <span style="COLOR: #008080">2</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />doBusiness(session);<br /></span> <span style="COLOR: #008080">3</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />session.close();聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">鍏抽棴session</span> </div> <p> <br />鑷充簬澶勭悊閫熷害鍛紝涓嶄細(xì)鎱㈠埌鍝効鍘葷殑錛屽凡緇忚瘯楠岃繃浜嗐? - )<br /><br />榪樼瓑浠涔堬紝璧跺揩璇曡瘯鍚э紒<br /></p> <img src ="http://m.tkk7.com/liaojiyong/aggbug/93454.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/liaojiyong/" target="_blank">liaojiyong</a> 2007-01-12 15:30 <a href="http://m.tkk7.com/liaojiyong/archive/2007/01/12/93454.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Hibernate 娣卞叆鐮旂┒涔婥riteria(杞?http://m.tkk7.com/liaojiyong/archive/2007/01/12/93427.htmlliaojiyongliaojiyongFri, 12 Jan 2007 06:27:00 GMThttp://m.tkk7.com/liaojiyong/archive/2007/01/12/93427.htmlhttp://m.tkk7.com/liaojiyong/comments/93427.htmlhttp://m.tkk7.com/liaojiyong/archive/2007/01/12/93427.html#Feedback0http://m.tkk7.com/liaojiyong/comments/commentRss/93427.htmlhttp://m.tkk7.com/liaojiyong/services/trackbacks/93427.html鏈榪戝湪欏圭洰涓嬌鐢?/span> Spring 鍜?/span> Hibernate 榪涜寮鍙戯紝鏈夋劅浜?/span> Criteria 姣旇緝濂界敤錛屽湪鏌ヨ鏂規(guī)硶璁捐涓婂彲浠ョ伒媧葷殑鏍規(guī)嵁 Criteria 鐨勭壒鐐規(guī)潵鏂逛究鍦拌繘琛屾煡璇㈡潯浠剁殑緇勮銆傛墍浠ョ幇鍦ㄥ Hibernate 鐨?/span> Criteria 娣卞叆鐮旂┒涓涓嬨傘?/span> Hibernate Reference 銆嬪強緗戜笂鍏跺畠涓浜涜祫鏂欏 Criteria 宸茬粡鍋氫簡寰堝浠嬬粛銆傛湰鏂囦富瑕佹槸浠?/span> Criteria 鐨勭粨鏋勫叆鎵嬫潵榪涜鍒嗘瀽銆?/span>

聽聽聽聽聽聽 濡傚浘 1 銆?/span> Hibernate 璁捐浜?/span> CriteriaSpecification 浣滀負(fù) Criteria 鐨勯《綰ф帴鍙o紝鍏朵笅闈㈡彁渚涗簡 Criteria 鍜?/span> DetachedCriteria 銆?/span>

Criteria 鍜?/span> DetachedCriteria 鐨勪富瑕佸尯鍒湪浜庡垱寤虹殑褰㈠紡涓嶄竴鏍鳳紝 Criteria 鏄湪綰跨殑錛屾墍浠ュ畠鏄敱 Hibernate Session 榪涜鍒涘緩鐨勶紱鑰?/span> DetachedCriteria 鏄綰跨殑錛屽垱寤烘椂鏃犻渶 Session 錛?/span> DetachedCriteria 鎻愪緵浜?/span> 4 涓潤鎬佹柟娉?/span> forClass(Class) 鎴?/span> forEntityName(Name) 榪涜 DetachedCriteria 瀹炰緥鐨勫垱寤恒?/span> Spring 鐨勬鏋舵彁渚涗簡

getHibernateTemplate().findByCriteria(detachedCriteria) 鏂規(guī)硶鍙互寰堟柟渚垮湴鏍規(guī)嵁

DetachedCriteria 鏉ヨ繑鍥炴煡璇㈢粨鏋溿?/span>

濡傚浘 1 錛?/span> Criteria 鍜?/span> DetachedCriteria 鍧囧彲浣跨敤 Criterion 鍜?/span> Projection 璁劇疆鏌ヨ鏉′歡銆傚彲浠ヨ緗?/span> FetchMode( 鑱斿悎鏌ヨ鎶撳彇鐨勬ā寮?/span> ) 錛岃緗帓搴忔柟寮忋傚浜?/span> Criteria 榪樺彲浠ヨ緗?/span> FlushModel 錛堝啿鍒?/span> Session 鐨勬柟寮忥級鍜?/span> LockMode 錛堟暟鎹簱閿佹ā寮忥級銆?/span>

涓嬮潰灝卞 Criterion 鍜?/span> Projection 榪涜璇︾粏璇存槑銆?/span>

聽聽聽聽聽聽

鍥?/span> 1

聽聽聽聽聽聽 Criterion 鏄?/span> Criteria 鐨勬煡璇㈡潯浠躲?/span>

Criteria 鎻愪緵浜?/span> add(Criterion criterion) 鏂規(guī)硶鏉ユ坊鍔犳煡璇㈡潯浠躲傚浘 2 鏄?/span> Criterion 鐨勭粨鏋勫浘銆?/span> Criterion 鎺ュ彛鐨勪富瑕佸疄鐜板寘鎷細(xì) Example 銆?/span> Junction 鍜?/span> SimpleExpression 銆傝?/span> Junction 鐨勫疄闄呬嬌鐢ㄦ槸瀹冪殑涓や釜瀛愮被 conjunction 鍜?/span> disjunction 錛屽垎鍒槸浣跨敤 AND 鍜?/span> OR 鎿嶄綔絎﹁繘琛屾潵鑱旂粨鏌ヨ鏉′歡闆嗗悎銆?/span>

Criterion 鐨勫疄渚嬪彲浠ラ氳繃 Restrictions 宸ュ叿綾繪潵鍒涘緩錛?/span> Restrictions 鎻愪緵浜嗗ぇ閲忕殑闈欐佹柟娉曪紝濡?/span> eq 錛堢瓑浜庯級銆?/span> ge 錛堝ぇ浜庣瓑浜庯級銆?/span> between 絳夋潵鏂規(guī)硶鐨勫垱寤?/span> Criterion 鏌ヨ鏉′歡

錛?/span> SimpleExpression 瀹炰緥錛夈傞櫎姝や箣澶栵紝 Restrictions 榪樻彁渚涗簡鏂規(guī)硶鏉ュ垱寤?/span> conjunction 鍜?/span> disjunction 瀹炰緥錛岄氳繃寰璇ュ疄渚嬬殑 add(Criteria) 鏂規(guī)硶鏉ュ鍔犳煡璇㈡潯浠跺艦鎴愪竴涓煡璇㈡潯浠墮泦鍚堛?/span>

鑷充簬 Example 鐨勫垱寤烘湁鎵涓嶅悓錛?/span> Example 鏈韓鎻愪緵浜嗕竴涓潤鎬佹柟娉?/span> create(Object entity) 錛屽嵆鏍規(guī)嵁涓涓璞★紙瀹為檯浣跨敤涓竴鑸槸鏄犲皠鍒版暟鎹簱鐨勫璞★級鏉ュ垱寤恒傜劧鍚庡彲浠ヨ緗竴浜涜繃婊ゆ潯浠訛細(xì)

Example exampleUser =Example.create(u)

.ignoreCase() // 蹇界暐澶у皬鍐?/span>

.enableLike(MatchMode.ANYWHERE);

// 瀵?/span> String 綾誨瀷鐨勫睘鎬э紝鏃犺鍦ㄩ偅閲屽煎湪閭i噷閮藉尮閰嶃傜浉褰撲簬 %value%


鍥?/span> 2

聽聽聽聽聽聽

Project 涓昏鏄 Criteria 鑳藉榪涜鎶ヨ〃鏌ヨ錛屽茍鍙互瀹炵幇鍒嗙粍銆?/span> Project 涓昏鏈?/span> SimpleProjection 銆?/span> ProjectionList 鍜?/span> Property 涓変釜瀹炵幇銆傚叾涓?/span> SimpleProjection 鍜?/span> ProjectionList 鐨勫疄渚嬪寲鏄敱鍐呭緩鐨?/span> Projections 鏉ュ畬鎴愶紝濡傛彁渚涚殑 avg 銆?/span> count 銆?/span> max 銆?/span> min 銆?/span> sum 鍙互璁╁紑鍙戣呭緢瀹規(guī)槗瀵規(guī)煇涓瓧孌佃繘琛岀粺璁℃煡璇€?/span>

聽聽聽聽聽聽 Property 鏄鏌愪釜瀛楁榪涜鏌ヨ鏉′歡鐨勮緗紝濡傞氳繃

聽聽聽聽聽 Porperty.forName(鈥渃olor鈥?.in(new String[]{鈥渂lack鈥?鈥漴ed鈥?鈥漺rite鈥潁); 鍒欏彲浠ュ垱寤轟竴涓?/span> Project 瀹炰緥銆傞氳繃 criteria 鐨?/span> add(Project) 鏂規(guī)硶鍔犲叆鍒版煡璇㈡潯浠朵腑鍘匯?/span>


鍥?/span> 3

聽聽聽聽聽聽

聽聽聽聽聽聽 浣跨敤 Criteria 榪涜鏌ヨ錛屼富瑕佽娓呮櫚鐨勬槸 Hibernate 鎻愪緵浜嗛偅浜涚被鍜屾柟娉曟潵婊¤凍寮鍙戜腑鏌ヨ鏉′歡鐨勫垱寤哄拰緇勮錛屽叾緇撴瀯灞傛濡備綍銆傝繖鏍蜂嬌鐢ㄨ搗鏉ヤ究鍙緱蹇冨簲鎵嬨?/span>



]]>
Hibernate 娣卞叆鐮旂┒涔?Criteria 錛堣漿錛?/title><link>http://m.tkk7.com/liaojiyong/archive/2006/07/24/59843.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Mon, 24 Jul 2006 08:23:00 GMT</pubDate><guid>http://m.tkk7.com/liaojiyong/archive/2006/07/24/59843.html</guid><wfw:comment>http://m.tkk7.com/liaojiyong/comments/59843.html</wfw:comment><comments>http://m.tkk7.com/liaojiyong/archive/2006/07/24/59843.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/liaojiyong/comments/commentRss/59843.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/liaojiyong/services/trackbacks/59843.html</trackback:ping><description><![CDATA[ <div id="umoqk2k" class="postbody"> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span> </span> </p> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏈榪戝湪欏圭洰涓嬌鐢?/span> <span lang="EN-US">Spring</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">Hibernate</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪涜寮鍙戯紝鏈夋劅浜?/span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">姣旇緝濂界敤錛屽湪鏌ヨ鏂規(guī)硶璁捐涓婂彲浠ョ伒媧葷殑鏍規(guī)嵁</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勭壒鐐規(guī)潵鏂逛究鍦拌繘琛屾煡璇㈡潯浠剁殑緇勮銆傛墍浠ョ幇鍦ㄥ</span> <span lang="EN-US">Hibernate</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨?/span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">娣卞叆鐮旂┒涓涓嬨傘?/span> <span lang="EN-US">Hibernate Reference</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆嬪強緗戜笂鍏跺畠涓浜涜祫鏂欏</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">宸茬粡鍋氫簡寰堝浠嬬粛銆傛湰鏂囦富瑕佹槸浠?/span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勭粨鏋勫叆鎵嬫潵榪涜鍒嗘瀽銆?/span> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span> </span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">濡傚浘</span> <span lang="EN-US">1</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">Hibernate</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">璁捐浜?/span> <span lang="EN-US">CriteriaSpecification</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">浣滀負(fù)</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勯《綰ф帴鍙o紝鍏朵笅闈㈡彁渚涗簡</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勪富瑕佸尯鍒湪浜庡垱寤虹殑褰㈠紡涓嶄竴鏍鳳紝</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏄湪綰跨殑錛屾墍浠ュ畠鏄敱</span> <span lang="EN-US">Hibernate Session</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪涜鍒涘緩鐨勶紱鑰?/span> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏄綰跨殑錛屽垱寤烘椂鏃犻渶</span> <span lang="EN-US">Session</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎻愪緵浜?/span> <span lang="EN-US">4</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">涓潤鎬佹柟娉?/span> <span lang="EN-US">forClass(Class)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎴?/span> <span lang="EN-US">forEntityName(Name)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪涜</span> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">瀹炰緥鐨勫垱寤恒?/span> <span lang="EN-US">Spring</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勬鏋舵彁渚涗簡</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US">getHibernateTemplate().findByCriteria(detachedCriteria)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏂規(guī)硶鍙互寰堟柟渚垮湴鏍規(guī)嵁</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏉ヨ繑鍥炴煡璇㈢粨鏋溿?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">濡傚浘</span> <span lang="EN-US">1</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">DetachedCriteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍧囧彲浣跨敤</span> <span lang="EN-US">Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">Projection</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">璁劇疆鏌ヨ鏉′歡銆傚彲浠ヨ緗?/span> <span lang="EN-US">FetchMode(</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鑱斿悎鏌ヨ鎶撳彇鐨勬ā寮?/span> <span lang="EN-US">)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛岃緗帓搴忔柟寮忋傚浜?/span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪樺彲浠ヨ緗?/span> <span lang="EN-US">FlushModel</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛堝啿鍒?/span> <span lang="EN-US">Session</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勬柟寮忥級鍜?/span> <span lang="EN-US">LockMode</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛堟暟鎹簱閿佹ā寮忥級銆?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">涓嬮潰灝卞</span> <span lang="EN-US">Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">Projection</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪涜璇︾粏璇存槑銆?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 <img src="http://m.tkk7.com/images/blogjava_net/faith/13332/o_Criteria.JPG" /></span> <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /?> <v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> </v:stroke> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> </v:f> <v:f eqn="sum @0 1 0"> </v:f> <v:f eqn="sum 0 0 @1"> </v:f> <v:f eqn="prod @2 1 2"> </v:f> <v:f eqn="prod @3 21600 pixelWidth"> </v:f> <v:f eqn="prod @3 21600 pixelHeight"> </v:f> <v:f eqn="sum @0 0 1"> </v:f> <v:f eqn="prod @6 1 2"> </v:f> <v:f eqn="prod @7 21600 pixelWidth"> </v:f> <v:f eqn="sum @8 21600 0"> </v:f> <v:f eqn="prod @7 21600 pixelHeight"> </v:f> <v:f eqn="sum @10 21600 0"> </v:f> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"> </v:path> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?> <o:lock v:ext="edit" aspectratio="t"> </o:lock> </v:shapetype> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍥?/span> <span lang="EN-US">1</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <o:p>聽</o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span>Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏄?/span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勬煡璇㈡潯浠躲?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎻愪緵浜?/span> <span lang="EN-US">add(Criterion criterion)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏂規(guī)硶鏉ユ坊鍔犳煡璇㈡潯浠躲傚浘</span> <span lang="EN-US">2</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏄?/span> <span lang="EN-US">Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勭粨鏋勫浘銆?/span> <span lang="EN-US">Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎺ュ彛鐨勪富瑕佸疄鐜板寘鎷細(xì)</span> <span lang="EN-US">Example</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">Junction</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">SimpleExpression</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆傝?/span> <span lang="EN-US">Junction</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勫疄闄呬嬌鐢ㄦ槸瀹冪殑涓や釜瀛愮被</span> <span lang="EN-US">conjunction</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">disjunction</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛屽垎鍒槸浣跨敤</span> <span lang="EN-US">AND</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">OR</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎿嶄綔絎﹁繘琛屾潵鑱旂粨鏌ヨ鏉′歡闆嗗悎銆?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US">Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勫疄渚嬪彲浠ラ氳繃</span> <span lang="EN-US">Restrictions</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">宸ュ叿綾繪潵鍒涘緩錛?/span> <span lang="EN-US">Restrictions</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎻愪緵浜嗗ぇ閲忕殑闈欐佹柟娉曪紝濡?/span> <span lang="EN-US">eq</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛堢瓑浜庯級銆?/span> <span lang="EN-US">ge</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛堝ぇ浜庣瓑浜庯級銆?/span> <span lang="EN-US">between</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">絳夋潵鏂規(guī)硶鐨勫垱寤?/span> <span lang="EN-US">Criterion</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏌ヨ鏉′歡</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛?/span> <span lang="EN-US">SimpleExpression</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">瀹炰緥錛夈傞櫎姝や箣澶栵紝</span> <span lang="EN-US">Restrictions</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪樻彁渚涗簡鏂規(guī)硶鏉ュ垱寤?/span> <span lang="EN-US">conjunction</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">disjunction</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">瀹炰緥錛岄氳繃寰璇ュ疄渚嬬殑</span> <span lang="EN-US">add(Criteria)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏂規(guī)硶鏉ュ鍔犳煡璇㈡潯浠跺艦鎴愪竴涓煡璇㈡潯浠墮泦鍚堛?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鑷充簬</span> <span lang="EN-US">Example</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勫垱寤烘湁鎵涓嶅悓錛?/span> <span lang="EN-US">Example</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏈韓鎻愪緵浜嗕竴涓潤鎬佹柟娉?/span> <span lang="EN-US">create(Object entity)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">錛屽嵆鏍規(guī)嵁涓涓璞★紙瀹為檯浣跨敤涓竴鑸槸鏄犲皠鍒版暟鎹簱鐨勫璞★級鏉ュ垱寤恒傜劧鍚庡彲浠ヨ緗竴浜涜繃婊ゆ潯浠訛細(xì)</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US">Example exampleUser =Example.create(u)</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 126pt"> <span lang="EN-US">.ignoreCase() //</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">蹇界暐澶у皬鍐?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 105pt; TEXT-INDENT: 21pt"> <span lang="EN-US">.enableLike(MatchMode.ANYWHERE);</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 105pt"> <span lang="EN-US">//</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">瀵?/span> <span lang="EN-US">String</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">綾誨瀷鐨勫睘鎬э紝鏃犺鍦ㄩ偅閲屽煎湪閭i噷閮藉尮閰嶃傜浉褰撲簬</span> <span lang="EN-US">%value%</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> <img src="http://m.tkk7.com/images/blogjava_net/faith/13332/o_Criterion.JPG" /> <br />鍥?/span> <span lang="EN-US">2</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US">Project </span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">涓昏鏄</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鑳藉榪涜鎶ヨ〃鏌ヨ錛屽茍鍙互瀹炵幇鍒嗙粍銆?/span> <span lang="EN-US">Project</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">涓昏鏈?/span> <span lang="EN-US">SimpleProjection</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">ProjectionList</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">Property</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">涓変釜瀹炵幇銆傚叾涓?/span> <span lang="EN-US">SimpleProjection</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍜?/span> <span lang="EN-US">ProjectionList</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨勫疄渚嬪寲鏄敱鍐呭緩鐨?/span> <span lang="EN-US">Projections</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏉ュ畬鎴愶紝濡傛彁渚涚殑</span> <span lang="EN-US">avg</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">count</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">max</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">min</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">銆?/span> <span lang="EN-US">sum</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍙互璁╁紑鍙戣呭緢瀹規(guī)槗瀵規(guī)煇涓瓧孌佃繘琛岀粺璁℃煡璇€?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span>Property</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏄鏌愪釜瀛楁榪涜鏌ヨ鏉′歡鐨勮緗紝濡傞氳繃</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽 </span>Porperty.forName(鈥渃olor鈥?.in(new String[]{鈥渂lack鈥?鈥漴ed鈥?鈥漺rite鈥潁);</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鍒欏彲浠ュ垱寤轟竴涓?/span> <span lang="EN-US">Project</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">瀹炰緥銆傞氳繃</span> <span lang="EN-US">criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鐨?/span> <span lang="EN-US">add(Project)</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鏂規(guī)硶鍔犲叆鍒版煡璇㈡潯浠朵腑鍘匯?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center"> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"> <img src="http://m.tkk7.com/images/blogjava_net/faith/13332/o_Projection.JPG" /> <br />鍥?/span> <span lang="EN-US">3</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <span style="mso-tab-count: 1">聽聽聽聽聽聽 </span> </span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">浣跨敤</span> <span lang="EN-US">Criteria</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">榪涜鏌ヨ錛屼富瑕佽娓呮櫚鐨勬槸</span> <span lang="EN-US">Hibernate</span> <span style="FONT-FAMILY: 瀹嬩綋; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">鎻愪緵浜嗛偅浜涚被鍜屾柟娉曟潵婊¤凍寮鍙戜腑鏌ヨ鏉′歡鐨勫垱寤哄拰緇勮錛屽叾緇撴瀯灞傛濡備綍銆傝繖鏍蜂嬌鐢ㄨ搗鏉ヤ究鍙緱蹇冨簲鎵嬨?/span> </p> </div> <img src ="http://m.tkk7.com/liaojiyong/aggbug/59843.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/liaojiyong/" target="_blank">liaojiyong</a> 2006-07-24 16:23 <a href="http://m.tkk7.com/liaojiyong/archive/2006/07/24/59843.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浠?/8鍘熷垯鎸囧鎴戜滑鐨勫簳灞傛鏋惰璁?錛堣漿錛?/title><link>http://m.tkk7.com/liaojiyong/archive/2006/07/21/59314.html</link><dc:creator>liaojiyong</dc:creator><author>liaojiyong</author><pubDate>Thu, 20 Jul 2006 17:35:00 GMT</pubDate><guid>http://m.tkk7.com/liaojiyong/archive/2006/07/21/59314.html</guid><wfw:comment>http://m.tkk7.com/liaojiyong/comments/59314.html</wfw:comment><comments>http://m.tkk7.com/liaojiyong/archive/2006/07/21/59314.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/liaojiyong/comments/commentRss/59314.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/liaojiyong/services/trackbacks/59314.html</trackback:ping><description><![CDATA[     鎽樿: 鍘熷垱鏂囩珷錛岃漿杞借娉ㄦ槑浣滆咃細(xì)Nomad錛屽嚭澶勶細(xì) www.jialing.net 聽聽聽聽 鎴戞兂寰堝浜洪兘鍚榪団?/8鈥濆師鍒欙紝鏈変漢鐮旂┒榪囷紝榪欎笘鐣屼笂璐㈠瘜鐨?0錛呴泦涓湪20錛呯殑浜烘墜閲岋紝鑰屽彟澶?0錛呯殑浜哄彧鎷ョ敤20錛呯殑璐㈠瘜銆傚疄闄呯殑鍟嗕笟涓紝鎴戜滑搴旇鏇村叧娉ㄥぇ瀹㈡埛錛屽洜涓哄鎴烽噷20錛呯殑澶у鎴鳳紝瀵規(guī)垜浠礎(chǔ)鐚殑鍒╂鼎鍙兘浼?xì)鍗犲?0錛咃紝榪欎簺閮芥槸鏈夌粺璁″鍩虹鐨勬暟鎹偮犅犅?鍦ㄥ簲鐢ㄨ蔣浠剁殑鐮斿彂涓悓鏍烽伒瀹堣繖涓師...  <a href='http://m.tkk7.com/liaojiyong/archive/2006/07/21/59314.html'>闃呰鍏ㄦ枃</a><img src ="http://m.tkk7.com/liaojiyong/aggbug/59314.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/liaojiyong/" target="_blank">liaojiyong</a> 2006-07-21 01:35 <a href="http://m.tkk7.com/liaojiyong/archive/2006/07/21/59314.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://14743592.com" target="_blank">亚洲jjzzjjzz在线观看</a>| <a href="http://junyehome.com" target="_blank">最近中文字幕2019高清免费</a>| <a href="http://513573.com" target="_blank">亚洲一卡二卡三卡</a>| <a href="http://joob4s.com" target="_blank">亚洲精品无码MV在线观看</a>| <a href="http://ydstbj.com" target="_blank">久久亚洲精品视频</a>| <a href="http://cijishiye.com" target="_blank">你懂的网址免费国产</a>| <a href="http://xww678.com" target="_blank">在线看亚洲十八禁网站</a>| <a href="http://jpvv8.com" target="_blank">亚洲伊人久久大香线蕉在观</a>| <a href="http://68996500.com" target="_blank">亚洲国产成人片在线观看无码</a>| <a href="http://jmzc888.com" target="_blank">亚洲精品美女久久久久99小说</a>| <a href="http://bjbf99.com" target="_blank">成年女人喷潮毛片免费播放</a>| <a href="http://bjtjchem.com" target="_blank">99精品视频在线观看免费播放 </a>| <a href="http://shbailongma.com" target="_blank">国产精品免费视频观看拍拍</a>| <a href="http://www-bajie.com" target="_blank">亚洲精品无码人妻无码</a>| <a href="http://viviker.com" target="_blank">亚洲国产成人久久综合一区</a>| <a href="http://992fanli.com" target="_blank">亚洲AV成人一区二区三区AV</a>| <a href="http://56kaifa.com" target="_blank">国内精品久久久久久久亚洲</a>| <a href="http://44168888.com" target="_blank">亚洲а∨天堂久久精品</a>| <a href="http://f2dai.com" target="_blank">国产午夜精品久久久久免费视</a>| <a href="http://tlyyt.com" target="_blank">亚洲一区在线观看视频</a>| <a href="http://aizaicc.com" target="_blank">亚洲好看的理论片电影</a>| <a href="http://727744.com" target="_blank">亚洲国产精品一区二区久久hs </a>| <a href="http://jcmy5188.com" target="_blank">一级毛片免费毛片毛片</a>| <a href="http://gycat.com" target="_blank">小说区亚洲自拍另类</a>| <a href="http://cz655.com" target="_blank">亚洲欧美日韩综合久久久久</a>| <a href="http://caocl1024liu.com" target="_blank">亚洲AV综合色区无码二区偷拍 </a>| <a href="http://www1688mz.com" target="_blank">亚欧在线精品免费观看一区</a>| <a href="http://bbby6.com" target="_blank">国产精品免费一区二区三区四区</a>| <a href="http://www-kj5799.com" target="_blank">亚洲黄色高清视频</a>| <a href="http://66cws.com" target="_blank">亚洲第一成年男人的天堂</a>| <a href="http://820111com.com" target="_blank">久久亚洲AV永久无码精品</a>| <a href="http://fsweicheng.com" target="_blank">亚洲高清视频一视频二视频三</a>| <a href="http://hkcdk.com" target="_blank">波多野结衣免费视频观看</a>| <a href="http://popodino.com" target="_blank">无码国产精品一区二区免费模式 </a>| <a href="http://by6216.com" target="_blank">日本不卡在线观看免费v</a>| <a href="http://deyingwh.com" target="_blank">色妞WWW精品免费视频 </a>| <a href="http://maomi02.com" target="_blank">亚洲AV成人无码网站</a>| <a href="http://www-63228.com" target="_blank">久久亚洲AV成人无码国产电影 </a>| <a href="http://zhidianzh.com" target="_blank">国产小视频免费观看</a>| <a href="http://959901cc.com" target="_blank">免费国产一级特黄久久</a>| <a href="http://njchxf.com" target="_blank">亚洲高清免费视频</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>