锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品无码久久久久APP ,亚洲一卡一卡二新区无人区,亚洲欧美日韩中文二区http://m.tkk7.com/jackybu/category/1616.html<a ><b><font color=red>鍏辨湁<script src=http://fastonlineusers.com/online.php?d=jackybu.blogjava.net></script>浜哄湪鍚屾椂闃呰姝log</font></b></a>zh-cnWed, 28 Feb 2007 03:39:20 GMTWed, 28 Feb 2007 03:39:20 GMT60[杞琞hibernate:one-to-one鐨勫涔犲皬緇忛獙http://m.tkk7.com/jackybu/articles/10501.html杈?/dc:creator>杈?/author>Fri, 19 Aug 2005 05:45:00 GMThttp://m.tkk7.com/jackybu/articles/10501.htmlhttp://m.tkk7.com/jackybu/comments/10501.htmlhttp://m.tkk7.com/jackybu/articles/10501.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/10501.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/10501.html one-to-one鍦╤ibernate涓彲浠ョ敤鏉ヤ綔涓轟袱寮犺〃涔嬮棿鐨勪富閿叧鑱旓紝榪欎篃鏄痟ibernate涓富閿叧鑱旂殑涓縐嶇敤娉曪紝榪欐牱鍦ㄤ竴寮犺〃涓殑ID錛屽湪鐢熸垚鍙﹀涓寮犺〃鐨勫悓鏃跺洖鑷姩鎻掑叆鍒扮浉搴旂殑ID瀛楁涓幓錛岀浉搴旂殑XML鏂囦歡璁劇疆姣旇緝綆鍗曪紝涓句緥濡備笅錛?BR>
    <!-- 寤虹珛涓瀵逛竴鐨勫埌Address鐨勬槧灝勶紝榪欎釜鏄啓鍦║ser鐨刋ML閰嶇疆鏂囦歡涓殑 -->
    <!-- 鐩稿簲鐨刄ser bean錛圥O錛変腑涔熻娣誨姞灞炴?com.xx.Address  address-->
    <one-to-one name="address" cascade="all" class="com.xx.Address"/>
   
   <!-- cascade鐨勫睘鎬ц緗笉鍐嶉噸澶嶄簡錛屽彲浠ユ煡鐪媓ibernate鏂囨。 -->

    <!-- 寤虹珛涓瀵逛竴鐨勫埌User鐨勬槧灝勶紝榪欎釜鏄啓鍦ˋddress鐨刋ML閰嶇疆鏂囦歡涓殑 -->
    <!-- 鐩稿簲鐨凙ddress bean錛圥O錛変腑涔熻娣誨姞灞炴?com.xx.User user--> -->
    <one-to-one name="user" class="com.xx.User" constrained="true"/>

      涓轟簡鍦ˋddress涓嬌鐢║ser涓殑涓婚敭ID鍊鹼紝鎴戜滑闇瑕佽緗瓵ddress涓殑涓婚敭鐢熸垚瑙勫垯錛屽涓嬫墍紺猴紝閲囩敤foreign鍏抽敭瀛?BR>
   <id column="ID" name="id" type="long" unsaved-value="0">
      <generator class="foreign">
        <param name="property">user</param> 
      </generator>
   </id>


      榪欓噷闇瑕佹敞鎰忕殑鏄痯roperty鐨勫睘鎬у煎繀欏諱笌涓婇潰鍒癠ser鐨勬槧灝勬墍濉啓鐨刵ame灞炴у間竴鑷?/EM>錛岃繖鏍峰氨瀹屾垚浜唎ne-to-one鐨勬槧灝勫叧緋匯?BR>
涓婇潰鐨勮繃紼嬮兘寰堢畝鍗曪紝涓嬮潰鎴戞潵璇磋榪欓噷闇瑕佹敞鎰忕殑鍦版柟錛?BR>
  1.   鍦ㄨ緗睘鎬D鐨勬椂鍊欏繀欏繪敞鎰忓瓧孌電殑闀垮害錛屽絎旇呰繖鏍蜂嬌鐢╫racle鐨剆equence鏉ョ敓鎴怚D錛屽叾闀垮害鏈?4浣嶄箣闀匡紝鍒欏簲閫夋嫨hibernate綾誨瀷long錛屽搴旂殑瀹炰綋涓簲閫夋嫨Long錛岃繖鏍蜂笉浼氬嚭鐜版孩鍑虹殑鎯呭喌銆?/STRONG>


  2.   鍦ㄦ祴璇曠殑鏃跺欏繀欏昏娉ㄦ剰榪欎袱寮犺〃涔嬮棿鍥犱負宸茬粡瀛樺湪浜嗕竴瀵逛竴鐨勫叧緋伙紝鎵浠ユ垜浠笉鑳藉彧鍐?BR>         user.setAddress(address);
         鑰屽拷鐣ヤ簡
         address.setUser(user);
         榪欐牱鍦ㄥ仛鎻掑叆鐨勬椂鍊欎細鎶ュ嚭attempted to assign id from null one-to-one property: address鐨勯敊璇紝榪欎竴鐐瑰垵瀛﹁呬細緇忓父鐘紝絎旇呬篃鏄叾涓箣涓銆?BR>

 3.   濡傛灉涓嶅啓cascade="all"鎴栬呭啓鎴恈ascade="none"鐨勮瘽錛屽嵆浣夸綘鍐欎簡
         user.setAddress(address);
         address.setUser(user);
       涔熶笉浼氬彂鐢熶換浣曚簨鎯咃紝鍙湁user浼氳瀛樺偍銆?BR>
浠ヤ笂鏄竴浜涚瑪鑰呯粡鍘嗙殑灝忕粡楠岋紝濡傛灉鏈変笉瀵圭殑鍦版柟嬈㈣繋鎸囨銆?img src ="http://m.tkk7.com/jackybu/aggbug/10501.html" width = "1" height = "1" />

]]>
[杞琞One-to-one鍏崇郴鏄犲皠http://m.tkk7.com/jackybu/articles/10497.html杈?/dc:creator>杈?/author>Fri, 19 Aug 2005 05:30:00 GMThttp://m.tkk7.com/jackybu/articles/10497.htmlhttp://m.tkk7.com/jackybu/comments/10497.htmlhttp://m.tkk7.com/jackybu/articles/10497.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/10497.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/10497.html瀵逛簬hibernate鐨?/SPAN>one-to-one鍏崇郴鏉ヨ錛屽ぇ瀹跺父甯告妸瀹冨拷鐣ワ紝璁や負瀹冨緢綆鍗曪紝鍏跺疄榪欓噷闈㈡湁浜涚粏鑺傞渶瑕佹敞鎰忥紝鍦?/SPAN>hibernate3涓湁涓ょ瀹炵幇one-to-one鐨勬柟娉曪細絎竴縐嶅氨鏄敤many-to-one鏉ヤ唬鏇夸竴瀵瑰錛屽叾瀹?/SPAN>one-to-one涔熷氨鏄?/SPAN>many-to-one鐨勪竴縐嶆瀬闄愭柟寮忥紝鑻ユ妸many-to-one璁劇疆unique="true"錛屽垯榪欐椂鍊欑殑many-to-one瀹炶川涓婂氨鏄?/SPAN>one-to-one;榪欓噷涓轟粈涔堣兘澶熺敤many-to-one鏉ヤ唬鏇?/SPAN>one-to-one鍛紵鏈鏍規湰鐨勬槸涓や釜瀵硅薄蹇呴』鏈変竴涓瓧孌電浉鍏寵仈錛岄偅涔堜綘涔熷彂鐜?/SPAN>one-to-one涓病鏈?/SPAN>column灞炴э紝涔熷氨鏄笉鑳藉鎶?/SPAN>one-to-one鐨勮繖縐嶅叧緋葷敓鎴愪竴涓瓧孌?/SPAN>/灞炴э紝鑰?/SPAN>many-to-one鍙互錛屽畠鏈?/SPAN>column灞炴с傛墍浠ワ紝璇翠簡榪欎箞澶氾紝浣犲簲璇ユ槑鐧戒負浠涔堝彲浠ョ敤many-to-one鏉ヤ唬鏇?/SPAN>one-to-one.

 

瀵逛簬榪欑鏂規硶瑕佹敞鎰忓嚑鐐癸細

渚嬪錛屼笅闈㈢殑浠嬬粛涓?/SPAN>use涓殑涓や釜瀛楁鍚屾椂褰卞皠adress錛屽彧鑳藉瀹炵幇鍗曞悜one-to-one,涔熷氨鏄粠use鍒?/SPAN>adress錛屼笉鑳藉瀹炵幇浠?/SPAN>adress鍒?/SPAN>use.鐒朵絾涓嬮潰涔熶粙緇嶄簡鍙互浣跨敤澶嶆潅鐨勬柟娉曟潵瑙e喅錛屼絾鏄緱涓嶅伩澶便?/SPAN>

 

絎簩縐嶆柟娉曪細鍩轟簬涓婚敭鍏寵仈鐨?/SPAN>one-to-one,榪欑鏂規硶姣旇緝鐩存帴銆備篃灝辨槸璁?/SPAN>adress鐨勪富閿煎拰use鐨勪竴鏍峰氨鍙互浜嗭紝閫氳繃

<id name="id" column="ADDRESS_ID">

<generator class="foreign">

<param name="property">user</param>

</generator>

鏉ユ妸adress鐨勪富閿煎拰use鐨勪富閿肩浉絳夈傚叾浣欑殑璁劇疆閮芥槸灝忎簨銆?/SPAN>

 

瀵逛簬鍒濆鑰呮潵璇村簲璇ユ敞鎰忥細鍗曞湪use鍜?/SPAN>adress涓緗?/SPAN>one-to-one鏄笉琛岀殑錛岄渶瑕佽緗笂闈㈢殑浠g爜錛岄渶瑕佸疄鐜?SPAN lang=EN-US style="FONT-SIZE: 14pt; mso-font-kerning: 0pt">one-to-one涓ょ鐨勫璞′富閿肩浉鍚岋紝榪欐槸鏈涓昏鐨?/SPAN>銆傝繖涔熸槸one-to-one涓?/SPAN>many-to-one鐨勪笉鍚屼箣澶勩傚簲褰撴敞鎰忋?/SPAN>

                                                                                           fasttalk

                                                                              m.tkk7.com/asktalk

 

 

 

Using a foreign key association

The easiest way to represent the association from User to its billingAddress is to use a <many-to-one> mapping with a unique constraint on the foreign key. This may surprise you, since many doesn鈥檛 seem to be a good description of either end of a one-to-one association! However, from Hibernate鈥檚 point of view, there isn鈥檛 much difference between the two kinds of foreign key associations. So, we add a foreign key column named BILLING_ADDRESS_ID to the USER table and map it as follows:

 

<many-to-one name="billingAddress"

class="Address"

column="BILLING_ADDRESS_ID"

cascade="save-update"/>

 

Note that we鈥檝e chosen save-update as the cascade style. This means the Address will become persistent when we create an association from a persistent User. Probably,  cascade="all" makes sense for this association, since deletion of the User should result in deletion of the Address. (Remember that Address now has its own entity lifecycle.)

 

Our database schema still allows duplicate values in the BILLING_ADDRESS_ID column of the USER table, so two users could have a reference to the same address. To make this association truly one-to-one, we add unique="true" to the <many-toone> element, constraining the relational model so that there can be only one user per address:

 

<many-to-one name="billingAddress"

class="Address"

column="BILLING_ADDRESS_ID"

cascade="all"

unique="true"/>

 

This change adds a unique constraint to the BILLING_ADDRESS_ID column in the DDL generated by Hibernate鈥攔esulting in the table structure illustrated by figure 6.7.

 

But what if we want this association to be navigable from Address to User in Java?  From chapter 3, you know how to turn it into a bidirectional one-to-many collection鈥攂ut we鈥檝e decided that each Address has just one User, so this can鈥檛 be the right solution. We don鈥檛 want a collection of users in the Address class. Instead, we add a property named user (of type User) to the Address class, and map it like so in the mapping of Address:

 

<one-to-one name="user"

class="User"

property-ref="billingAddress"/>

 

This mapping tells Hibernate that the user association in Address is the reverse direction of the billingAddress association in User.

 

In code, we create the association between the two objects as follows:

Address address = new Address();

address.setStreet("646 Toorak Rd");

address.setCity("Toorak");

address.setZipcode("3000");

Transaction tx = session.beginTransaction();

User user = (User) session.get(User.class, userId);

address.setUser(user);

user.setBillingAddress(address);

tx.commit();

image002.gif

To finish the mapping, we have to map the homeAddress property of User. This is easy enough: we add another <many-to-one> element to the User metadata, mapping a new foreign key column, HOME_ADDRESS_ID:

 

<many-to-one name="homeAddress"

class="Address"

column="HOME_ADDRESS_ID"

cascade="save-update"

unique="true"/>

 

The USER table now defines two foreign keys referencing the primary key of the ADDRESS table: HOME_ADDRESS_ID and BILLING_ADDRESS_ID.

 

Unfortunately, we can鈥檛 make both the billingAddress and homeAddress associations bidirectional, since we don鈥檛 know if a particular address is a billing address or a home address. (We can鈥檛 decide which property name鈥攂illingAddress or homeAddress鈥攖o use for the property-ref attribute in the mapping of the user property.) We could try making Address an abstract class with subclasses HomeAddress and BillingAddress and mapping the associations to the subclasses. This approach would work, but it鈥檚 complex and probably not sensible in this case.  Our advice is to avoid defining more than one one-to-one association between any two classes. If you must, leave the associations unidirectional. If you don鈥檛 have more than one鈥攊f there really is exactly one instance of Address per User鈥攖here is an alternative approach to the one we鈥檝e just shown. Instead of defining a foreign key column in the USER table, you can use a primary key association.

 

Using a primary key association

Two tables related by a primary key association share the same primary key values.  The primary key of one table is also a foreign key of the other. The main difficulty with this approach is ensuring that associated instances are assigned the same primary key value when the objects are saved. Before we try to solve this problem, let鈥檚 see how we would map the primary key association.

 

For a primary key association, both ends of the association are mapped using the <one-to-one> declaration. This also means that we can no longer map both the billing and home address, only one property. Each row in the USER table has a corresponding row in the ADDRESS table. Two addresses would require an additional table, and this mapping style therefore wouldn鈥檛 be adequate. Let鈥檚 call this single address property address and map it with the User:

 

<one-to-one name="address"

class="Address"

cascade="save-update"/>

 

Next, here鈥檚 the user of Address:

<one-to-one name="user"

class="User"

constrained="true"/>

 

The most interesting thing here is the use of constrained="true". It tells Hibernate that there is a foreign key constraint on the primary key of ADDRESS that refers to the primary key of USER.

 

Now we must ensure that newly saved instances of Address are assigned the same identifier value as their User. We use a special Hibernate identifier-generation strategy called foreign:

 

<class name="Address" table="ADDRESS">

<id name="id" column="ADDRESS_ID">

<generator class="foreign">

<param name="property">user</param>

</generator>

</id>

...

<one-to-one name="user"

class="User"

constrained="true"/>

</class>

 

The <param> named property of the foreign generator allows us to name a one-toone association of the Address class鈥攊n this case, the user association. The foreign generator inspects the associated object (the User) and uses its identifier as the identifier of the new Address. Look at the table structure in figure 6.8.  The code to create the object association is unchanged for a primary key association;  it鈥檚 the same code we used earlier for the many-to-one mapping style.

image004.gif



]]>
[杞琞one-to-one鐨勬晥鐜囬棶棰橈紝鐢╫ne-to-many鏉ユ浛浠o紵http://m.tkk7.com/jackybu/articles/10495.html杈?/dc:creator>杈?/author>Fri, 19 Aug 2005 05:26:00 GMThttp://m.tkk7.com/jackybu/articles/10495.htmlhttp://m.tkk7.com/jackybu/comments/10495.htmlhttp://m.tkk7.com/jackybu/articles/10495.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/10495.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/10495.html
         From tableMain

浠呬粎鎵ц鐪嬭搗鏉ュ崄鍒嗙畝鍗曠殑涓鏉¤鍙ワ紝浣犳墍鏈熸湜鐨勬槸浠栫揣绱ф煡璇_MAIN榪欏紶涓昏〃錛屽彲鏄粨鏋滅‘瀹瀐ibernate閫氳繃澶氫釜澶栬繛鎺ュ皢鎵鏈夌殑瀛愯〃涓鍙f皵鐨勫叏閮ㄦ煡璇㈠嚭鏉?BR>
         select * from t_main main outer join t_sub1 sub1 on main.id = sub1.id outer join t_sub2 sub2 on main.id = sub2.id...

 濡傛鐨勬晥鐜囩粷瀵硅浣犲ご鐥涗笉宸詫紝涓嶄粎濡傛錛屽鏋滀綘閫氳繃棣栧厛鑾峰緱瀛愯〃t_sub1鐨勬煇涓富閿甀D錛岀劧鍚庨氳繃榪欎釜涓婚敭鏌ヨ鍑哄瓙琛ㄥ璞★紝鍦ㄥ叧鑱旇嚦浣忚〃錛屽悓鏍風殑鎯呭喌鍙堜細鍙戠敓錛屽張浼氱敓鎴愮被浼肩殑SQL璇彞錛岃繖鏍蜂竴鏉ョ湅鏉ュ浜庤繖涓璁″簲鐢╫ne-to-one鏈韓灝辨槸涓縐嶉敊璇紝鏄繖鏍峰悧錛?BR>
         鎴栬鏈変漢璁や負鎴戜滑鍦ㄦ瘡涓猳ne-to-one涓姞鍏azy="true"榪欎釜灞炴т細鏉滅粷涓婅堪鎯呭喌鐨勫彂鐢燂紝緇忚繃絎旇呯殑璇佸疄鍗充究浣犲姞鍏ヤ簡lazy="true"錛屼篃涓嶄細甯︽潵浠諱綍鐨勬敼鍙橈紱鍙堟垨鑰呭湪hibernate.config涓姞鍏etch depth灞炴т互鍙婂湪姣忎釜鍏寵仈涓緗畂uter-join="false"錛岃繖浜涢兘涓嶄細寮曡搗鏈川涓婄殑鍙樺寲錛屽姞鍏uter-join="false"鍏跺疄緇撴灉鍙槸灝嗗師鏈夌殑outer join璇彞鏀瑰彉鎴愬鏉ql璇彞鑰屽凡錛屽茍娌″彂鐢熶粈涔堟湰璐ㄥ彉鍖栵紝鍙嶈屾晥鐜囨洿浣庝簡銆?BR>
         璇ユ庝箞鍔炲憿錛熸垜浠厛浠旂粏鐮旂┒涓涓媜ne-to-one鐨勬蹇碉紝one to one浠h〃涓瀵逛竴錛屽湪涓鑸殑妯″瀷涓緢灝戜細閬囧埌one-to-one榪欑姒傚康錛屽洜涓轟粬鍗佸垎寮鴻皟涓瀵逛竴鐨勬蹇碉紝灝卞ソ姣斾竴涓漢浠栧彧鏈変竴涓韓浣撳拰涓涓ご鑰屽凡錛屽ご鍜岃韓浣撴槸鍗佸垎濂界殑渚嬪瓙錛屽洜涓烘湁韜綋蹇呭畾鍙湁涓涓ご錛岃屼笖璇村埌浜嗚韓浣撳繀瀹氳璇村ご錛屽氨濂藉儚鐪嬩簡鏌愪釜濂沖鐨勮韓鏉愬繀瀹氭兂鐭ラ亾濂圭殑闀跨浉濡備綍錛?_-錛夛紝鎵浠ュ湪榪欐椂鎴戜滑浣跨敤one-to-one錛屽洜涓鴻繖縐嶄竴瀵逛竴鐨勫叧緋繪槸寰堝己鐨勶紝鑰屼笖浠庡璞′腑鍙栧緱body蹇呭畾浼氬彇寰椾粬鎵鍏寵仈鐨刪ead錛岃繖鏍風殑鎯呭喌涓嬩嬌鐢╫uter-join鏄崄鍒嗘柟渚垮拰鏈夋晥鐜囩殑錛屽洜涓哄畠浣跨敤浜唎uter join鏌ヨ浠庤岄伩鍏嶄簡涓ゆ潯鍒版暟鎹簱鐨勬煡璇㈣鍙ワ紝鑰屼笖鍦ㄨ繖縐嶆儏鍐典笅涔熷彧闇瑕佸湪body_hbm.xml涓緗竴涓猳ne-to-one鍗沖彲錛屾墍浠ュ湪榪欑紜疄鏄竴瀵逛竴鑰屼笖鍦ㄤ富琛ㄤ腑涓瀵逛竴鐨勫叧鑱斾釜鏁幫紙鍗充富琛ㄤ腑one-to-one鏍囩錛夊崄鍒嗗皯鐨勬儏鍐典笅錛屼嬌鐢╫ne-to-one鏄竴縐嶅緢涓嶉敊鐨勮В鍐沖姙娉曘?BR>
         濡傛灉涓涓富琛ㄤ細瀵瑰涓瓙琛ㄩ兘榪涜one-to-one鍏寵仈鍛紝灝卞儚鎴戜滑涓寮濮嬮亣鍒扮殑榪欑鎯呭喌錛屾瘮濡備綘涓嶄粎浠呭彧鎯充簡瑙i偅涓綘涓剰鐨勫コ瀛╃殑韜潗鍜岃劯铔嬶紝鑰屼笖榪樻兂鐭ラ亾浠栫殑瀛﹀巻錛岃韓涓栫瓑絳変竴鍒囷紝鍦ㄨ繖縐嶆儏鍐典笅錛屽鏋滄垜浠兘鏄敤澶氫釜one-to-one鍦ㄤ富琛ㄤ腑鐨勮瘽錛岄偅鎯呭喌姝e鎴戜滑涓寮濮嬬湅瑙佺殑錛屾槸鍗佸垎鍙曠殑錛岃鎬庝箞鍋氬憿錛熶笉濡ㄨ冭檻涓涓嬩嬌鐢╫ne-to-many錛屼粈涔堬紝many?涓寮濮嬪惉鍒癿any榪欎釜璇嶇殑鏃跺欙紝鎴戜篃瑙夊緱鎸烘儕璁剁殑榪欐槑鏄庢槸澶氫釜涓瀵逛竴鐨勫叧鑱斾負浠涔堣鐢ㄥ埌many鍛紵鍏跺疄many騫舵病鏈変竴瀹氳璇存槸澶т簬涓鐨勶紝浣犲氨鍙湪瀹冪殑many涓瓨鍦ㄤ竴涓叧鑱斿畠鏈夎兘涔冧綘浣曞憿錛熷鏋滅敤鍒癿any鐨勮瘽錛屾垜浠氨闇瑕佹敼鍔ㄦ暟鎹〃鐨勮璁′簡錛屽湪姣忎釜鏈夊叧榪炵殑瀛愯〃涓姞鍏ヤ竴鍒梞ain_id浠h〃涓昏〃涓璁板綍鐨勪富閿瓙孌靛鹼紝鍙渶瑕佽繖鏍峰瓙鏀瑰姩灝卞彲浠ヤ簡錛岃繖鏍鋒墍甯︽潵鐨勬晥鏋滅粷瀵規槸鍊煎緱浣犺繖鏍峰仛鐨勶紝鐒跺悗鎴戜滑灝辨寜鐓т互寰鐨刼ne-to-many鏉ヨ璁″氨濂戒簡

         鍦╞ody.hbm.xml鍔犲叆錛堜竴鍒癶ead鐨勫叧鑱斾婦渚嬶紝鍏朵粬鐨勫叧鑱旀寜鐓ц繖鏍風殑鏍煎紡娣誨姞鍗沖彲錛?BR>         <set name="head" inverse="true" lazy="true" cascade="all-delete-orphan">
            <key column="ID0000"/>
            <one-to-many class="com.xx.Head"/>
          </set>

         鍦╤ead.hbm.xml鍔犲叆
         <many-to-one name="body" column="ID0000" class="com.xx.Body" not-null="true"/>

         琛屼簡錛岀粡榪囦笂闈㈢殑鏀瑰姩鎴戜滑灝辨憜鑴變簡鏌ヨ鏃跺涓猳uter-join鐨勫洶鎵幫紝鍙湪闇瑕佺殑鏃跺欐墠瀵瑰瓙琛ㄨ繘琛屾煡璇紝鍥犱負璁劇疆浜唋azy="true"錛屾墍浠ヤ竴鍒囩殑涓鍒囬兘鍦ㄦ垜浠殑棰勬枡涔嬩腑錛屾垜浠鏋滃笇鏈涜幏寰梑ody鐨勮瘽hibernate緇濆涓嶄細鎶婂畠鐨刪ead 涔熸煡璇㈠嚭鏉ワ紝鑺傜渷浜嗘煡璇㈡槸鎵闇瑕佺殑璐熸媴錛岄櫎闈炲埌浜嗘垜浠崄鍒嗛渶瑕乭ead鐨勬儏鍐墊墠浼氳繘琛屽叧鑱旀煡璇紝鑾峰緱鎵闇瑕佺殑head緇撴灉銆?BR>
         鎵浠ョ敱姝ょ湅鏉?FONT color=#0000ff>鍦╫ne-to-one榪欑涓瀵逛竴鐨勫叧緋諱笉鏄緢寮虹殑鎯呭喌涓嬶紝鎴栬呮槸鍦ㄤ竴寮犺〃涓瓨鍦ㄥ涓猳ne-to-one鐨勬儏鍐典笅錛屼嬌鐢╫ne-to-many鏉ヤ唬鏇縪ne-to-one涓嶅け涓轟竴縐嶄笉閿欑殑鍋氭硶錛屽綋鐒舵洿閲嶈鐨勮壇濂界殑鏁版嵁搴撹璁★紝hibernate姣曠珶鍙槸鏈紝鍗冧竾涓嶈鏈湯鍊掔疆銆?BR>

]]>
Hibernate鐨勬绱㈡柟寮?/title><link>http://m.tkk7.com/jackybu/articles/9687.html</link><dc:creator>杈?/dc:creator><author>杈?/author><pubDate>Tue, 09 Aug 2005 13:21:00 GMT</pubDate><guid>http://m.tkk7.com/jackybu/articles/9687.html</guid><wfw:comment>http://m.tkk7.com/jackybu/comments/9687.html</wfw:comment><comments>http://m.tkk7.com/jackybu/articles/9687.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/jackybu/comments/commentRss/9687.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/jackybu/services/trackbacks/9687.html</trackback:ping><description><![CDATA[<!--StartFragment --><FONT style="BACKGROUND-COLOR: #ff0000"> Q:</FONT><span id="wppqtec" class=postbody>Hibernate鐨勬绱㈡柟寮忔湁寰堝 <BR>瀵硅薄鍥劇殑瀵艱埅媯绱紝load/get媯绱紝HQL(find,Query)媯绱紝QBC(Criteria錛孮BE)媯绱互鍙婃湰鍦版暟鎹簱SQL媯绱? <BR>閭d箞錛屽湪瀹為檯搴旂敤涓埌搴曢夋嫨鍝竴縐嶆绱㈠ソ錛熷畠浠箣闂寸殑媯绱㈡湁鍝簺鑱旂郴鍜屽尯鍒憿錛?/SPAN> <BR><BR><!--StartFragment --><FONT style="BACKGROUND-COLOR: #ff0000"> A:(by Robbin)</FONT><span id="ivikkdh" class=postbody>HQL鍔熻兘鏈寮哄ぇ錛岄傚悎鍚勭鎯呭喌錛屼絾鏄姩鎬佹潯浠舵煡璇㈡瀯閫犺搗鏉ュ緢涓嶆柟渚?<BR>Criteria鏈閫傚悎鍔ㄦ佹潯浠舵煡璇紝涓嶅お閫傚悎緇熻鏌ヨ錛孮BE榪樹笉澶熷己澶э紝鍙傚悎鐩稿綋綆鍗曠殑鏌ヨ <BR>NativeSQL鍙互瀹炵幇鐗瑰畾鏁版嵁搴撶殑SQL錛屼絾鏄彲縐繪鎬у氨鐗虹壊浜?<BR><BR><BR>Hibernate2鐨凜riteria鍔熻兘涓嶅瀹屽杽錛屾墍浠ibernate2涓婇潰鍙敤鐨勫彧鏈塇QL鍜孨ativeSQL錛孒ibernate3鐨凜riteria宸茬粡闈炲父寮哄ぇ浜嗐?<BR><BR>鎴戠殑閫夋嫨鍘熷垯鏄細 <BR><BR>閽堝web搴旂敤鏉ヨ錛屽ぇ閮ㄥ垎甯歌鏌ヨ閮芥槸鍔ㄦ佹潯浠舵煡璇紝鎵浠ラ閫変嬌鐢–riteria錛屽茍涓擧ibernate3鎻愪緵浜咲etachedCriteria錛屽彲浠ュ湪web灞傛瀯閫犲ソDetachedCriteria鍐嶈繘鍏ession鎵ц鏌ヨ錛岄潪甯告柟渚垮疄鐢ㄧ殑鐗規с?<BR><BR>浣嗘槸娑夊強鍒扮粺璁℃煡璇㈠拰闈炲父澶嶆潅鐨勫叧鑱旀煡璇紝Criteria灝辨棤鑳戒負鍔涗簡錛岃繖縐嶆儏鍐典笅鎴戦夋嫨浣跨敤HQL銆?<BR><BR>鏈鍚庡鏋滃繀欏諱嬌鐢ㄦ煇浜涙暟鎹簱鐨勭壒鎬э紝渚嬪Oracle鐨?...connect with ... by"榪欐牱鐨凷QL錛屽垯閫夋嫨浣跨敤NativeSQL銆?/SPAN> <img src ="http://m.tkk7.com/jackybu/aggbug/9687.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/jackybu/" target="_blank">杈?/a> 2005-08-09 21:21 <a href="http://m.tkk7.com/jackybu/articles/9687.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://moushengguigz.com" target="_blank">久久精品国产亚洲麻豆</a>| <a href="http://www999973.com" target="_blank">男人的天堂网免费网站</a>| <a href="http://720880.com" target="_blank">亚洲神级电影国语版</a>| <a href="http://sxhnyl.com" target="_blank">国产偷窥女洗浴在线观看亚洲 </a>| <a href="http://yy6636.com" target="_blank">一本色道久久综合亚洲精品高清 </a>| <a href="http://8884493.com" target="_blank">亚洲资源在线视频</a>| <a href="http://uu313.com" target="_blank">亚洲综合图色40p</a>| <a href="http://zzttt04.com" target="_blank">国产小视频免费观看</a>| <a href="http://ccccccx.com" target="_blank">91免费精品国自产拍在线不卡</a>| <a href="http://zwdyw.com" target="_blank">久久国产乱子伦精品免费一</a>| <a href="http://601508.com" target="_blank">国产久爱免费精品视频</a>| <a href="http://ywgj50225.com" target="_blank">久久亚洲中文无码咪咪爱</a>| <a href="http://myzhoubian.com" target="_blank">亚洲中文字幕久久精品无码A</a>| <a href="http://33303339.com" target="_blank">亚洲高清中文字幕</a>| <a href="http://zuahowan.com" target="_blank">99久久亚洲综合精品成人网</a>| <a href="http://3c3w.com" target="_blank">亚洲精品你懂的在线观看</a>| <a href="http://173ba.com" target="_blank">亚洲午夜爱爱香蕉片</a>| <a href="http://rbthy.com" target="_blank">亚洲国产香蕉人人爽成AV片久久</a>| <a href="http://dingdingduo.com" target="_blank">大学生a级毛片免费观看</a>| <a href="http://whspmd.com" target="_blank">永久免费的网站在线观看</a>| <a href="http://jisuanq.com" target="_blank">成人免费黄色网址</a>| <a href="http://51a88.com" target="_blank">成人免费的性色视频</a>| <a href="http://9527paotui.com" target="_blank">国产成人精品免费午夜app</a>| <a href="http://ygloka.com" target="_blank">6080午夜一级毛片免费看6080夜福利 </a>| <a href="http://286513.com" target="_blank">日本高清高色视频免费</a>| <a href="http://yqstickers.com" target="_blank">aaa毛片免费观看</a>| <a href="http://dqcjlb.com" target="_blank">EEUSS影院WWW在线观看免费</a>| <a href="http://yiren2233.com" target="_blank">西西人体大胆免费视频</a>| <a href="http://h47h.com" target="_blank">美女黄频a美女大全免费皮</a>| <a href="http://xin-matai.com" target="_blank">综合一区自拍亚洲综合图区</a>| <a href="http://8654123.com" target="_blank">亚洲AV无码专区在线电影成人</a>| <a href="http://xsxdsb.com" target="_blank">亚洲日韩精品无码专区加勒比 </a>| <a href="http://w5524.com" target="_blank">91在线品视觉盛宴免费</a>| <a href="http://ahjmdd.com" target="_blank">在线观看免费人成视频色</a>| <a href="http://whdysdt.com" target="_blank">久久不见久久见免费影院</a>| <a href="http://pjappuiehjdkhsjkssd2.com" target="_blank">91麻豆最新在线人成免费观看</a>| <a href="http://lanoss.com" target="_blank">xxxx日本免费</a>| <a href="http://jiujiujingpin.com" target="_blank">色se01短视频永久免费</a>| <a href="http://788qj.com" target="_blank">免费毛片在线看片免费丝瓜视频</a>| <a href="http://555yyyy.com" target="_blank">国内精品免费视频自在线</a>| <a href="http://www6661126.com" target="_blank">日韩a级毛片免费视频</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>