<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    kapok

    垃圾桶,嘿嘿,我藏的這么深你們還能找到啊,真牛!

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      455 隨筆 :: 0 文章 :: 76 評論 :: 0 Trackbacks
    http://m.tkk7.com/jinfeng_wang/archive/2005/04/03/2798.html

     <list name="tracks" table="ALBUM_TRACKS" cascade="all">

          <meta attribute="use-in-tostring">true</meta>

          <key column="ALBUM_ID"/>

          <index column="POS"/>

          <composite-element class="com.oreilly.hh.AlbumTrack">

            <many-to-one name="track" class="com.oreilly.hh.Track" cascade="all">

              <meta attribute="use-in-tostring">true</meta>

              <column name="TRACK_ID"/>

            </many-to-one>

            <property name="disc" type="integer" not-null="true"/>

            <property name="positionOnDisc" type="integer" not-null="true"/>

          </composite-element>

        </list>

    The cascade attribute tells Hibernate that you want operations performed on a 'parent' object to be transitively applied to its 'child' or 'dependent' objects. It's applicable to all forms of collections and associations. There are several possible values to choose among. The most common are none (the default), save-update, delete, and all (which combines save-update and delete). You can also change the default from none to save-update throughout your entire mapping document by supplying a default-cascade attribute in the hibernate-mapping tag itself.

    級聯(cascade)屬性告訴hibernate:所有對父對象的操作都將付諸于子對象和依賴對象上。級聯可以應用于各種形式的集合和關聯中。這里級聯的具體取值可以有多個,最常用的有:none(默認值),save-update,delete和all(其中包含了save-update和delete)。你可以在hibernate-mappiong tag中通過設置default-casade屬性,修改這里的casade的默認值,例如修改其默認值為save-update。

    In our example, we want the tracks owned by an album to be automatically managed by the album, so that when we delete the album, its tracks are deleted. Note that we need to apply the
    cascade attribute both to the tracks collection and its constituent track element to achieve this. Also, by using a cascade value of all, we eliminate the need to explicitly save any Track objects we create for the album—the addAlbumTrack() method of Example 5-7 no longer needs the line:

       session.save(track);

    在我們的例子中,我們希望track完全由album自動掌管,當我們刪除album時,它的track也會被刪除。注意,這里我們需要在兩處設置casade屬性實現此任務:tracks集合和它的組成元素track。同樣,由于我們講casade設置為all,那么不再需要顯式的保存為album創建的track對象,5-7例子中的addAlbumTrack方法不再需要調用session.save(track)方法。

    By telling Hibernate that it's fully responsible for the relationship between an album and its track, we enable it to persist tracks when they're added to the album as well as delete them when the album itself is deleted.


    通過高知hibernate,由其完全負責album和track直接的關系,可以保證track在加入到album時自動保存,在album刪除時自動刪除。

    Delegating this sort of bookkeeping to the mapping layer can be very convenient, freeing you to focus on more abstract and important tasks, so it is worth using when appropriate. It's reminiscent of the liberation provided by Java's pervasive garbage collection, but it can't be as comprehensive because there is no definitive way to know when you're finished with persistent data by performing reachability analysis; you need to indicate it by calling
    delete() and establishing lifecycle connections. The trade-off between flexibility and simple automation is yours to make, based on the nature of your data and the needs of your project.
    將這樣的任務完全交代給持久層使得我們的任務更加的簡便,可以讓我們將注意力投注于更抽象更重要的業務,因此恰當的使用casade是值得的,這就像java的垃圾收集一樣,使我們的工作得到了一定的解放。但是,由于目前并沒有任何的可達性分析方法,可以確切的知道“你是否已經不再需要此持久層數據”,因此你必須調用delete()方法,才能建立起此生命周期鏈接。你必須依據你的數據的特點和項目的需要,在靈活性和自動化的簡單性進行權衡。

    For example, if you use Collections methods to remove a Track from an Album's tracks property, this breaks the link between the Album and Track but does not actually delete the Track record. Even if you later delete the entire Album, this Track will remain, because it wasn't linked to the Album at the time that it was deleted.
    例如:如果你使用Album的tracks collection的remove方法,刪除一個track,這將會移除album和track直接的鏈接,但是它并沒真正的刪除track記錄。即使你后來整個的刪除album,這個track也將會繼續保留著,因為此時該track已經和album失去了鏈接。
    posted on 2005-04-03 23:06 笨笨 閱讀(195) 評論(0)  編輯  收藏 所屬分類: J2EE 、ALL
    主站蜘蛛池模板: 最近中文字幕完整版免费高清| 在线观看www日本免费网站| 国产精品午夜免费观看网站| 99re6热视频精品免费观看| 日本高清免费网站| 久久久婷婷五月亚洲97号色| 国产亚洲精品AAAA片APP| 叮咚影视在线观看免费完整版| 成年女人毛片免费播放视频m| 亚洲无人区一区二区三区| 2020国产精品亚洲综合网| 在线观看片免费人成视频播放| 性感美女视频在线观看免费精品 | 亚洲免费黄色网址| 亚洲一级片免费看| 国产成人精品亚洲日本在线 | 亚洲激情中文字幕| 一区二区三区视频免费| 免费做爰猛烈吃奶摸视频在线观看 | 亚洲欧美不卡高清在线| 99久久人妻精品免费二区| 久久亚洲精品无码aⅴ大香| 中文字幕不卡免费高清视频| 亚洲毛片基地4455ww| 男人的好看免费观看在线视频 | 久久99国产亚洲高清观看首页| 亚洲精品无码你懂的| 四虎影视在线永久免费看黄 | 亚洲中文字幕无码日韩| 久久精品夜色噜噜亚洲A∨| 曰批全过程免费视频网址| 三根一起会坏掉的好痛免费三级全黄的视频在线观看 | 337p日本欧洲亚洲大胆裸体艺术 | 久久久久久久久亚洲| 天堂亚洲免费视频| 亚洲爆乳无码一区二区三区| 成人免费无码视频在线网站| 男女超爽视频免费播放| 国产免费久久精品久久久| 少妇性饥渴无码A区免费 | 免费福利在线观看|