• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Hibernate作為數據持久層的分析和研究2

    發表于:2008-06-02來源:作者:點擊數: 標簽:Hibernatehibernate研究數據
    關鍵字:hibernate,數據持久化,JDBC, EJB,JDO 2、創建映射文檔 映射文檔是用來定義持久數據和在需要時保存關于對象的持久域、關聯、子類和代理的XML文檔。對于每個持久對象和以名字class_name.hbm.xml保存的文件來說,都要創建一個映射文檔。在class_name
    關鍵字:hibernate,數據持久化,JDBC, EJB,JDO

      2、創建映射文檔

      映射文檔是用來定義持久數據和在需要時保存關于對象的持久域、關聯、子類和代理的XML文檔。對于每個持久對象和以名字class_name.hbm.xml保存的文件來說,都要創建一個映射文檔。在class_name.hbm.xml中class_name就是對象的類名,下面是Event.hbm.xml的內容。

    <!DOCTYPE hibernate-mapping PUBLIC

    "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

    <hibernate-mapping>
    ?。糲lass name="com.ubipass.cip.Event" table="EVENTS">
     ?。糹d name="id" column="uid" type="long">
      ?。糶enerator class="increment"/>
     ?。?id>
     ?。紁roperty name="date" column="event_date" type="timestamp"/>
     ?。紁roperty name="title" column="event_title" type="string"/>
    ?。?class>
    </hibernate-mapping>

      映射文檔在應用啟動時編譯,它可為Hibernate 提供關于持久對象的相應類、它們的結構、它們應該映射到哪個數據庫表格、以及如何映射的信息。Hibernate 也使用這些映射文檔,分別利用內建設備SchemaExport和CodeGenerator來生成相應的數據庫模式和stub Java類。

      3、生成用于持久對象的stub Java類

      在創建了映射文檔之后這個任務就變得簡單的多。stub類的創建使用Hibernate的內建設備 CodeGenerator ,執行一個簡單的命令就可以完成。,命令的語法如下:

    java -cp classpath net.sf.hibernate.tool.hbm2java.CodeGenerator

    options mapping_files

      它為classpath、options、和mapping_files參數提供了恰當的值。下面是通過映射文檔Event.hbm.xml生成的stub java 類的部分代碼。
     
    package com.ubipass.cip
    public class Event {
     private String title;
     ……
     Event(){ }
     public Long getId() {
      return id;
     }
     private void setId(Long id) {
      this.id = id;
     }
     ……
    }

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>