锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲成a人片毛片在线,在线精品自拍亚洲第一区,亚洲精品夜夜夜妓女网http://www.tkk7.com/dragonofson/category/12321.htmlzh-cnFri, 02 Mar 2007 05:58:32 GMTFri, 02 Mar 2007 05:58:32 GMT60Hibernate甯哥敤鏌ヨ璇彞http://www.tkk7.com/dragonofson/articles/53788.htmlDragonofsonDragonofsonMon, 19 Jun 2006 06:56:00 GMThttp://www.tkk7.com/dragonofson/articles/53788.htmlhttp://www.tkk7.com/dragonofson/comments/53788.htmlhttp://www.tkk7.com/dragonofson/articles/53788.html#Feedback0http://www.tkk7.com/dragonofson/comments/commentRss/53788.htmlhttp://www.tkk7.com/dragonofson/services/trackbacks/53788.htmlHib鐨勬绱㈡柟寮?br />1'瀵艱埅瀵硅薄鍥炬绱㈡柟寮忋傞氳繃宸茬粡鍔犺澆鐨勫璞★紝璋冪敤.iterator()鏂規硶鍙互寰楀埌order瀵硅薄
濡傛灉鏄嬈℃墽琛屾鏂規硶錛孒ib浼氫粠鏁版嵁搴撳姞杞藉叧鑱旂殑order瀵硅薄錛屽惁鍒欏氨浠庣紦瀛樹腑寰楀埌銆?br />2'OID媯绱㈡柟寮忋傞氳繃session鐨刧et錛宭oad鏂規硶鐭ラ亾浜哋ID鐨勬儏鍐典笅鍙互浣跨敤
3'HQL媯绱㈡柟寮忋備嬌鐢ㄩ潰鍚戝璞$殑HQL鏌ヨ璇彞session鐨刦ind鏂規硶鍒╃敤HQL鏉ユ煡璇?br />4'QBC媯绱㈡柟寮忋傚埄鐢≦BCAPI鏉ユ绱㈠畠鏄皝瑁呬簡鍩轟簬瀛楃涓茬殑鏌ヨ璇彞
5'鏈湴鐨凷QL媯绱㈡柟寮忋備嬌鐢ㄦ湰鍦版暟鎹簱鐨凷QL鏌ヨ璇彞Hib浼氳礋璐f妸媯绱㈠埌鐨凧DBC緇撴灉闆嗘槧灝勪負鎸佷箙鍖栧璞″浘銆?br />
浜旂媯绱㈡柟寮忕殑浣跨敤鍦哄悎鍜岀壒鐐癸細

HQL聽錛毬犳槸闈㈠悜瀵硅薄鐨勬煡璇㈣璦錛屽悓SQL鏈変簺鐩鎬技鏄疕ib涓渶甯哥敤鐨勬柟寮忋?br />聽聽聽聽聽聽聽鏌ヨ璁懼畾鍚勭鏌ヨ鏉′歡銆?br />聽聽聽聽聽聽聽鏀寔鎶曞獎鏌ヨ錛屾绱㈠嚭瀵硅薄鐨勯儴鍒嗗睘鎬с?br />聽聽聽聽聽聽聽鏀寔鍒嗛〉鏌ヨ錛屽厑璁鎬嬌鐢╤aving鍜実roup聽by
聽聽聽聽聽聽聽鎻愪緵鍐呭埗鐨勮仛闆嗗嚱鏁幫紝sum()錛宮in()錛宮ax()
聽聽聽聽聽聽聽鑳借皟鐢ㄧ敤鎴風殑鑷畾涔塖QL
聽聽聽聽聽聽聽鏀寔瀛愭煡璇紝宓屽叆寮忔煡璇?br />聽聽聽聽聽聽聽鏀寔鍔ㄦ佺粦瀹氬弬鏁?br />寤鴻浣跨敤Query鎺ュ彛鏇挎崲session鐨刦ind鏂規硶銆?br />聽聽聽Query聽Q聽=聽session.createQuery("from聽customer聽as聽c聽where聽c.name聽=聽:customerName"聽+聽"and聽c.age聽=聽:customerAge");
聽聽聽query.setString聽("customerName"聽,聽"tom");
聽聽聽query.setInteger("customerAge"聽,聽"21");
聽聽聽list聽result聽=聽query.list();
QBC聽:聽聽QBCAPI鎻愪緵浜嗗彟涓縐嶆柟寮忥紝涓昏鏄疌riteria鎺ュ彛銆丆riterion鎺ュ彛鍜孍xpression綾?br />聽聽聽Criteria聽criteria聽=聽session.createCriteria(customer.class);
聽聽聽Criterion聽criterion1聽=聽Expression.like("name","t%");
聽聽聽Criterion聽criterion2聽=聽Expression.eq("age",new聽Integer(21));
聽聽聽Critera聽=聽criteria.add(criterion1)聽;
聽聽聽Critera聽=聽criteria.add(criterion2)聽;
聽聽聽list聽result聽=聽criteria.list();聽
聽聽聽鎴栨槸錛毬爈ist聽result聽=聽session.createCriteria(Customer.class).add(Expression.eq("this.name","tom")).list();聽
SQL聽:聽聽閲囩敤HQL鍜孮BC媯绱㈡椂錛孒ib鐢熸垚SQL璇彞閫傜敤鎵鏈夋暟鎹簱銆?br />聽聽聽Query聽query聽聽=聽session.createSQLQuery("select聽{c.*}聽from聽customers聽c聽where聽c.name聽like聽:聽customername聽"聽+聽"and聽c.age聽=聽:customerage","c",customer.calss);
聽聽聽query.setString("customername","tom");
聽聽聽query.setInteger("customerage","21");
聽聽聽list聽result聽=聽query.list();
/////////////澶氭佹煡璇?br />聽聽聽HQL聽錛歴ession.createQuery("from聽employee");
聽聽聽QBC聽錛歴ession.createCriteria(employee.class);
聽聽聽HQL聽:聽session.createQuery("from聽hourlyEmployee");
聽聽聽QBC聽:聽session.createCriteria(hourlyEmployee.class);
聽聽聽涓嬮潰鐨凥QL鏌ヨ璇彞灝嗘绱㈠嚭鎵鏈夌殑鎸佷箙鍖栧璞★細
聽聽聽from聽java.lang.Object聽;
聽聽聽from聽java.io.serializable聽;
////////////鏌ヨ鐨勬帓搴?br />聽聽聽1'鏌ヨ緇撴灉鎸夌収瀹㈡埛濮撳悕鍗囧簭鎺掑垪錛?br />聽聽聽HQL聽錛?br />聽聽聽聽聽聽聽聽Query聽query聽=聽session.createQuery聽("from聽customer聽c聽order聽by聽c.name");
聽聽聽QBC聽錛?br />聽聽聽聽聽聽聽聽Criteria聽criteria聽=聽session.createCriteria(customer.class);
聽聽聽聽聽聽聽聽criteria.addOrder(order.asc("name"));
聽聽聽HQL聽:
聽聽聽聽聽聽聽聽Query聽query聽=聽session.createQuery聽("from聽customer聽c聽order聽by聽c.name聽asc聽,聽c.age聽desc");
聽聽聽QBC聽:
聽聽聽聽聽聽聽聽Criteria聽criteria聽=聽session.createCriteria(customer.class);
聽聽聽聽聽聽聽聽criteria.addOrder(order.asc聽("name"));
聽聽聽聽聽聽聽聽criteria.addOrder(order.desc("age"));聽

聽聽聽聽聽聽聽聽import聽net.sf.hibernate.pression.Order
聽聽聽聽聽聽聽聽import聽mypack.Order
聽聽聽聽聽聽聽聽...........
聽聽聽聽聽聽聽聽Criteria聽criteria聽=聽session.createCritria聽(mypack.Order.class);
聽聽聽聽聽聽聽聽criteria.addOrder(net.sf.hibernate.Order.asc("name"));
///////////HQL璇彞鐨勫弬鏁扮粦瀹歈uery鎺ュ彛鎻愪緵浜嗙粦瀹氬悇縐岺ib鏄犲皠綾誨瀷鐨勬柟娉曘?br />聽聽聽聽聽聽聽聽setBinary()
聽聽聽聽聽聽聽聽setString()
聽聽聽聽聽聽聽聽setBoolean()
聽聽聽聽聽聽聽聽setByte()
聽聽聽聽聽聽聽聽setCalendar()
聽聽聽聽聽聽聽聽setCharacter()
聽聽聽聽聽聽聽聽setDate()
聽聽聽聽聽聽聽聽setDouble()
聽聽聽聽聽聽聽聽setText()
聽聽聽聽聽聽聽聽setTime()
聽聽聽聽聽聽聽聽setTimestamp()
聽聽聽聽聽聽聽聽setEntity()//鎶婂弬鏁頒笌涓涓寔涔呭寲綾葷殑浜嬩緥緇戝畾lsit聽result聽=聽session.createQuery("from聽order聽o聽where聽o.customer聽=聽聽聽聽聽聽聽聽聽聽聽聽:customer").setEntity("customer"聽,聽customer).list聽;
聽聽聽聽聽聽聽聽setParameter()//緇戝畾浠繪剰綾誨瀷鐨勫弬鏁?br />聽聽聽聽聽聽聽聽setProperties()//鎶婂懡鍚嶅弬鏁頒笌涓涓璞$殑灞炴у肩粦瀹毬燪uery聽query聽=聽session.createQuery("from聽customer聽c聽where聽c.name聽=:聽聽聽聽聽name聽"聽+聽"and聽c.age聽=:age"聽);
聽聽聽聽聽聽聽聽Query.setProperties(customer);聽

榪囨護鏌ヨ緇撴灉涓殑閲嶅鍏冪礌聽
聽聽聽聽聽浣跨敤Set闆嗗悎鏉ュ幓闄ら噸澶嶅厓绱狅紱鎴栨槸浣跨敤distinct鍏冪礌
聽聽聽聽聽Iterator聽iterator聽=聽session.createQuery("select聽distinct聽c.name聽from聽customer聽").list().iterator();
聽聽聽聽聽while(iterator.hasnext()){
聽聽聽聽聽聽聽聽聽聽聽String聽name聽=聽(String)聽it.next()聽;
聽聽聽聽聽}
///////////浣跨敤鑱氶泦鍑芥暟
count();聽璁板綍鐨勬潯鏁?br />min();聽聽聽姹傛渶灝忓?br />max();聽聽聽姹傛渶澶у?br />avg();聽聽聽姹傚鉤鍧囧?br />sum();聽聽聽姹傚拰
1'鏌ヨcustomer涓殑鎵鏈夎褰曟潯鏁?br />聽聽聽integer聽i聽=聽(Integer)聽session.createQuery("select聽count(*)聽from聽customer").uniqueResult();
鍙湁鍦ㄧ‘瀹氬彧鏈変竴涓璞℃椂鍊欎嬌鐢╱niqueResult();
2'鏌ヨcustomer涓殑鎵鏈夊鎴風殑騫沖潎騫撮緞
聽聽聽integer聽i聽=聽(Integer)聽session.createQuery("select聽avg(c.age)聽from聽customer聽c聽").uniqueResult();
3'鏌ヨcustomer涓殑瀹㈡埛騫撮緞鐨勬渶澶у箋佹渶灝忓?br />涓涓暟緇勫彲浠ョ湅浣滀竴涓璞?br />聽聽聽object聽[]聽i聽=聽(Integer)聽session.createQuery("select聽max(c.age),min(c.age)聽from聽customer聽c聽").uniqueResult();
聽聽聽Integer聽Maxage聽=聽(Integer)聽i聽[0];
聽聽聽Integer聽Minage聽=聽(Integer)聽i聽[1];
4'緇熻customer涓殑瀹㈡埛鐨勫悕縐版暟鐩紝蹇界暐閲嶅鐨勫鍚?br />聽聽聽Integer聽cout聽=聽(Integer)聽session.createQuery("select聽count(distinct聽c.name)聽from聽customer聽c").uniqueResult();
////////////浣跨敤鍒嗙粍鏌ヨ
1'鎸夊鍚嶅垎緇勶紝緇熻customer涓殑鐩稿悓濮撳悕鐨勮褰曟暟鐩?br />聽聽聽Iterator聽iterator聽=聽(Integer)聽session.createQuery("select聽c.name聽,count(c)聽from聽customer聽c聽group聽by聽c.name").list.iterator();
聽聽聽while(iterator.hasnext()){
聽聽聽聽聽聽聽聽聽object[]聽p聽=聽(objcet[])iterator.next();
聽聽聽聽聽聽聽聽聽String聽name聽=聽p[0];
聽聽聽聽聽聽聽聽聽Integer聽cout聽=聽p[1];
聽聽聽}
2'鎸夊鎴峰垎緇勶紝緇熻姣忎釜瀹㈡埛鐨勮鍗曟暟閲?br />聽聽聽Iterator聽iterator聽=聽session.crateQuery("select聽c.id聽,c.name聽,聽count(o)聽from聽customer聽c聽join聽c.order聽o聽group聽by聽c.id聽").list().iterator;
聽聽聽while(iterator.hasnext()){
聽聽聽聽聽聽聽聽聽object[]聽p聽=聽(objcet[])iterator.next();
聽聽聽聽聽聽聽聽聽Integer聽id聽=聽p[0]
聽聽聽聽聽聽聽聽聽String聽name聽=聽p[1];
聽聽聽聽聽聽聽聽聽Integer聽cout聽=聽p[2];
聽聽聽}
3'緇熻姣忎釜瀹㈡埛鐨勮鍗曟諱環
聽聽聽Iterator聽iterator聽=聽session.crateQuery("select聽c.id聽,c.name,sum(o.price)聽from聽customer聽c聽join聽c.order聽o聽group聽by聽c.id").list.iterator();
聽聽聽while(iterator.hasnext()){
聽聽聽聽聽聽聽聽聽object[]聽p聽=聽(objcet[])iterator.next();
聽聽聽聽聽聽聽聽聽Integer聽id聽=聽p[0]
聽聽聽聽聽聽聽聽聽String聽name聽=聽p[1];
聽聽聽聽聽聽聽聽聽Double聽cout聽=聽p[2];
聽聽聽}
//////////鎶ヨ〃鐨勪紭鍖?br />浣跨敤HQL鏃跺鏋滃彧鏌ヨ瀵硅薄鐨勪竴閮ㄥ垎灞炴т笉浼氳繑鍥炴寔涔呭寲瀵硅薄
from聽customer聽c聽join聽c.order聽o聽group聽by聽c.age;//榪斿洖鎸佷箙鍖栧璞★紝鍗犵敤緙撳瓨銆?br />
select聽c.id聽,聽c.name聽,聽c.age聽,o.id聽,o.price聽from聽customer聽c聽join聽c.order聽o聽group聽by聽c.age聽//榪斿洖鍏崇郴鎬ф暟鎹紝涓嶅崰鐢╯ession鐨勭紦瀛橈紝鍙互涓篔VM鍥炴敹

/////////HQL瀛愭煡璇㈢殑闆嗗悎鍑芥暟灞炴?br />size()聽榪斿洖闆嗗悎涓厓绱犵殑鏁扮洰
minIndex()聽寤虹珛绱㈠紩鐨勯泦鍚堣幏寰楁渶灝忕殑绱㈠紩
maxIndex()聽寤虹珛绱㈠紩鐨勯泦鍚堣幏寰楁渶澶х殑绱㈠紩
minElement()聽瀵逛簬鍖呭惈鍩烘湰鍏冪礌鐨勯泦鍚堣幏寰楅泦鍚堟渶灝忕殑鍏冪礌
maxElement()聽瀵逛簬鍖呭惈鍩烘湰鍏冪礌鐨勯泦鍚堣幏寰楅泦鍚堟渶澶х殑鍏冪礌
element()聽鑾峰緱闆嗗悎涓殑鎵鏈夊厓绱?br />///////////Hibernate鐨勭紦瀛樼鐞?br />綆$悊涓綰х紦瀛橈紝涓嶅緩璁嬌鐢ㄤ笅鍒楁柟娉曟潵綆$悊涓綰х紦瀛?br />evict(Object聽o)浠庣紦瀛樹腑娓呴櫎鍙傛暟鎸囧畾鐨勬寔涔呭寲瀵硅薄
clear()娓呯┖緙撳瓨涓墍鏈夌殑鎸佷箙鍖栧璞?br />///////////鎵歸噺鏇存柊鍜屾壒閲忓垹闄?br />鎵歸噺鏇存柊customer琛ㄤ腑鐨勫勾榫勫ぇ浜庨浂鐨勬墍鏈夎褰曠殑AGE瀛楁錛?br />聽聽聽聽tx聽=聽session.beginTransaction();
聽聽聽聽Iterator聽customer聽=聽session.find("from聽customer聽c聽where聽c.age聽>聽0").iterator();
聽聽聽聽while(iterator.hasnext()){
聽聽聽聽聽聽聽聽customer聽customer聽=聽(customer)聽customer.next();
聽聽聽聽聽聽聽聽customer.setAge(customer.getAge()+1);
聽聽聽聽}
聽聽聽聽tx.commit();
聽聽聽聽session.close();//涓婅堪浠g爜瀵規暟鎹簱鎿嶄綔鏁堟灉涓嶅ソ鍙互浣跨敤涓嬪垪鐨凧DBCAPI鐩磋繛
聽聽聽
聽聽聽聽tx聽=聽session.beginTranscation();
聽聽聽聽Connection聽conn聽=聽session.connection();
聽聽聽聽Preparedstatement聽ps聽=聽conn.preparedstatment("update聽customer聽set聽age聽=聽age聽+聽1聽where聽age聽>聽0聽");
聽聽聽聽ps.executeupdate();
聽聽聽聽tx.commit();


]]>
主站蜘蛛池模板: 亚洲精品国产手机| 亚洲国产精品综合久久久| 亚洲精品理论电影在线观看| 久久午夜伦鲁片免费无码| 亚洲成人免费在线| 性色午夜视频免费男人的天堂| 国产亚洲精品观看91在线| 国产成人精品一区二区三区免费| 一级中文字幕乱码免费| 亚洲av日韩片在线观看| 一级做a爰黑人又硬又粗免费看51社区国产精品视 | 亚洲精品午夜在线观看| h视频在线观看免费完整版| 亚洲粉嫩美白在线| 又爽又黄无遮挡高清免费视频| 一区二区三区免费电影| 亚洲av永久无码精品漫画| 在线观看日本免费a∨视频| 亚洲国产精品成人AV在线| 亚洲精品无码久久不卡| 亚洲AV成人精品日韩一区| 免费吃奶摸下激烈视频| a级毛片免费播放| 亚洲国产超清无码专区| 日韩一级免费视频| aaa毛片视频免费观看| 亚洲经典在线观看| 午夜国产羞羞视频免费网站| 精品无码一级毛片免费视频观看| 亚洲伊人tv综合网色| 日韩成全视频观看免费观看高清| 黄色视屏在线免费播放| 亚洲六月丁香六月婷婷色伊人| 国产色婷婷精品免费视频| 久久精品免费一区二区三区| 亚洲色大18成人网站WWW在线播放| 国产精品亚洲mnbav网站 | 国产精品成人亚洲| 无码欧精品亚洲日韩一区| 最新69国产成人精品免费视频动漫| 三上悠亚在线观看免费|