freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

對象序列化和持久化(參考版)

2024-10-03 09:02本頁面
  

【正文】 (此題不需提交) 2020/11/4 Institute of Computer Software Nanjing University 95 。 子類屬性非常多,且對性能要求不是很嚴格時,優(yōu)先考慮 [方案 3]。在這種映射方式下,必須通過表的內(nèi)連接或左外連接來實現(xiàn)多態(tài)查詢和多態(tài)關聯(lián)。 } } ?xml version= encoding=UTF8? !DOCTYPE hibernatemapping PUBLIC //Hibernate/Hibernate Mapping DTD hibernatemapping package= class name=Honey table=thoney id name=id generator class=increment/ /id property name=name column=fooname/ property name=taste column=bartaste/ /class /hibernatemapping 對象-關系 映射 ? 繼承: ?方案 1:繼承關系中每個具體類對應一個表 ?子類父類各自映射到各自的關系上 ?特點:在這種映射方式中,每個子類除了映射自己的屬性外,還需要映射從父類繼承來下的屬性;此方式中關系數(shù)據(jù)模型完全不支持對象的繼承關系,不支持多態(tài)關聯(lián)和多態(tài)查詢 2020/11/4 Institute of Computer Software Nanjing University 86 對象-關系 映射 ? 繼承 ?方案 2:基類(根類)對應一個表 ?所有繼承自一個類的類都映射到一個表上 ?增加一欄標記當前記錄對應的對象的類 ?特點:這種映射方式支持多態(tài)關聯(lián)和多態(tài)查詢,并且能獲得最佳查詢性能,缺點是需要對關系數(shù)據(jù)模型進行非常規(guī)設計,在數(shù)據(jù)庫表中加入額外的區(qū)分各個子類的字段,此外,不能為所有子類的屬性對應的字段定義 not null約束,無法保證關系數(shù)據(jù)模型的數(shù)據(jù)完整性 2020/11/4 Institute of Computer Software Nanjing University 87 對象-關系 映射 ? 繼承 ?方案 3:每個類對應一個表 ?父類映射的關系與子映射的關系共享相同的主鍵值,父類關系只記錄本身的屬性,如果要查詢的是子類,則透過外鍵參考從父類表格中取得繼承而來的屬性值。} public void setTaste(String taste) { = taste。} public void setName(String name) { = name。} public void setId(Integer id) { = id。 private String taste。 Entity public class Honey { Id GeneratedValue private Integer id。 import 。 2020/11/4 Institute of Computer Software Nanjing University 79 No ORM ? 優(yōu)點:運行效率高 ? 缺點:嵌入大量 SQL語句,項目難以維護 ? 主要原因:業(yè)務處理邏輯和數(shù)據(jù)存取邏輯完全混雜在一塊 2020/11/4 Institute of Computer Software Nanjing University 80 Hibernate ? 它是連接 Java應用程序和關系數(shù)據(jù)庫的中間件 ? 它對 JDBC API進行了封裝,負責 Java對象的持久化 ? 在分層的軟件架構中它位于持久化層,封裝了所有數(shù)據(jù)訪問細節(jié),使業(yè)務邏輯層可以專注于實現(xiàn)業(yè)務邏輯 ? 持久化層( Persistence Layer),即專注于實現(xiàn)數(shù)據(jù)持久化應用領域的某個特定系統(tǒng)的一個邏輯層面,將數(shù)據(jù)使用者和數(shù)據(jù)實體相關聯(lián) ? 它是一種 ORM映射工具,能夠建立面向?qū)ο蟮挠蚰P秃完P系數(shù)據(jù)模型之間的映射 2020/11/4 Institute of Computer Software Nanjing University 81 2020/11/4 Institute of Computer Software Nanjing University 82 2020/11/4 Institute of Computer Software Nanjing University 83 對象-關系 映射 ? 簡單映射 ?將一個類中的一個數(shù)據(jù)成員定為關鍵字 ?其它數(shù)據(jù)成員為屬性 2020/11/4 Institute of Computer Software Nanjing University 84 2020/11/4 Institute of Computer Software Nanjing University 85 package 。 再使用 Connection 對象執(zhí)行更新 SQL 語句,以更新數(shù)據(jù)庫中的數(shù)據(jù)。 根據(jù)讀取到的數(shù)據(jù),按特定的業(yè)務邏輯進行計算。 用 Connection 對象執(zhí)行 SQL語句,獲得結果集 ResultSet 對象。 根據(jù)用戶的輸入組裝查詢 SQL 語句。 ? O/R Mapper則指以 O/R原理設計的持久化框架( Framework) ?hibernate, ibatis, jdo, etc. 2020/11/4 Institute of Computer Software Nanjing University 76 應用分層 ? 當前的現(xiàn)實: ?兩層結構 ?三層結構 ?N層結構 2020/11/4 Institute of Computer Software Nanjing University 77 2020/11/4 Institute of Computer Software Nanjing University 78 No ORM ? 使用 JDBC 操作數(shù)據(jù)庫,業(yè)務處理邏輯和數(shù)據(jù)存取邏輯是混雜在一起的。 2020/11/4 Institute of Computer Software Nanjing University 75 對象持久化框架 ? 對象關系映射( Object Relational Mapping,簡稱 ORM)是一種為了解決面向?qū)ο笈c關系數(shù)據(jù)庫存在的互不匹配的現(xiàn)象的技術。而關系數(shù)據(jù)庫不支持繼承的概念。 it cannot be a reference 2020/11/4 Institute of Computer Software Nanjing University 63 “The Carterhouse of Parma” “The Red and the Black” Title “Madame Bovary” “Eug?nie Grandet” date 1830 1839 1856 1833 pages 341 307 425 346 author “Stendahl” “Stendahl” “Flaubert” “Balzac” Relation books: field field name (= attribute) column tuple (= row) Operations ? Selection: date 1833 ? Projection ? Join 2020/11/4 Institute of Computer Software Nanjing University 64 “The Carterhouse of Parma” Title “Madame Bovary” date 1839 1856 pages 307 425 author “Stendahl” “Flaubert” Operations ? Selection ? Projection: on author ? Join 2020/11/4 Institute of Computer Software Nanjing University 65 author “Stendahl” “Flaubert” “Balzac” Operations ? Selection ? Projection ? Join: books authors 2020/11/4 Institute of Computer Software Nanjing University 66 “The Carterhouse of Parma” “The Red and the Black” Title “Madame Bovary” “Eug?nie Grandet” date 1830 1839 1856 1833 pages 341 307 425 346 author “Stendahl” “Stendahl” “Flaubert” “Balzac” real name “Henri Beyle” “Henri Beyle” “Gustave Flaubert” “Honor? de Balzac” birth 1783 1783 1821 1799 death 1842 1842 1880 1850 name “Stendahl” “Stendahl” “Flaubert” “Balzac” real name “Henri Beyle” “Henri Beyle” “Gustave Flaubert” “Honor? de Balzac” birth 1783 1783 1821 1799 death 1842 1842 1880 1850 Relation authors: Using relational databases with OO software ? Comparison of terms: ? Class library to provide operations (corresponding to embedded SQL). ? . JDBC 2020/11/4 Institute of Computer Software Nanjing University 67 Relational relation tuple field name OO class object attribute objectrelational interoperability ? Appropriate usage cases: ?You are writing an objectoriented system which must use and possibly update existing corporate data, stored in relational databases. ?Your OO software needs to store object structures simple enough to fit nicely in the relational view of things. ? Otherwise, Impedance mismatch! 2020/11/4 Institute of Computer Software Nanjing University 68 Impedance Mismatch ? 關系數(shù)據(jù)庫 ?數(shù)據(jù)結構規(guī)整,成員數(shù)目類型固定 ?結構簡單,成員類型屬于一個既定小集合 ?這些類型由大小固定的類型組合而成 ? 那么 ?大小不定的域? ?表示對象引用的域?基于引用的間接查詢? ?繼承? ? 更重要的是:對象 identity語義 2020/11/4 Institute of Computer Software Nanjing University 69 Objectoriented databases ? Remove impedance mismatch ? Overe con
點擊復制文檔內(nèi)容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1