国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Java 數據對象(JDO)介紹(二)

2019-11-18 10:48:02
字體:
來源:轉載
供稿:網友

  javax.jdo.PersistenceManagerFactory
  
  PersistenceManagerFactory接口 被用來獲得一個PersistenceManager 實例。這個接口中定義兩個工廠方法(有關工廠方法的內容可以參考Java設計模式)。
  
    public PersistenceManager getPersistenceManager()
    public PersistenceManager getPersistenceManager(String userid,
        String passWord)
  
  Because PersistenceManagerFactory is an interface, some vendor specific class, which implements this interface, must be used as a bootstrap mechanism. This should turn out to be the only vendor specific code that a JDO application uses. Because of this, the JDO specification suggests that an application level factory class be implemented which returns the apPRopriate instance of the PersistenceManagerFactory so that implementations may be swapped out with minimal impact on application code. Only the application's factory would need to be modified in this case.
  因為PersistenceManagerFactory 是一個接口,一些實現該接口的廠商特定的類必須通過一種“自舉”機制來使用。
  
    // SolarMetric's 實現PersistenceManagerFactory 接口的例子...
    PersistenceManagerFactory managerFactory =
        new com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory();
      // 獲得一個控制器 manager...
    PersistenceManager manager = managerFactory.getPersistenceManager();
  
  javax.jdo.PersistenceManager
  
  The PersistenceManager interface is the primary point of contact between a Java application and the JDO implementation. Application code uses a PersistenceManager to retrieve Java objects from the data store and to add Java objects to the data store. The PersistenceManager interface also serves as a factory for several other JDO components discussed below.
  PersistenceManager 接口是連接Java應用程序和JDO實現的要點。應用程序使用PersistenceManager 從數據存儲中獲得對象或者把一個Java對象放到數據存儲中。PersistenceManager 接口也為下面將要討論的幾個JDO組件提供服務。
  
  PersistenceManager 接口中定義了幾個方法來把JDO實例對象添加到數據存儲中。
  
    public abstract void makePersistent(Object);
    public abstract void makePersistentAll(Object[]);
    public abstract void makePersistentAll(java.util.Collection);
  
  通過下面幾個方法實現把JDO實例對象添加到數據存儲中的過程:
  
    // 獲得一個 manager...
    PersistenceManager manager = managerFactory.getPersistenceManager();
    // 下面的 Employee 必須擴展了 PersistenceCapable...
    Employee newEmployee = new Employee(...);
    manager.makePersistent(newEmployee);
  
  javax.jdo.Extent
  Extent (范圍)對象表示所有的在當前數據庫中實際的類對象。在PersistenceManager 中的一個工廠方法負責獲得一個Extent (范圍)對象。
  
    public Extent getExtent(Class persistenceCapableClass, boolean subclasses)
  
  Class參數標明了接收的對象類型。boolean 參數標明是否包含第一個參數指定的類的子類。
  
  Extent 接口定義了一個iterator()方法,它返回一個 java.util.Iterator來遍歷所有由Extent 描述的實例。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 仲巴县| 黔东| 长泰县| 盈江县| 祁阳县| 神池县| 陕西省| 北安市| 大理市| 额尔古纳市| 绍兴市| 炎陵县| 滦平县| 昌平区| 本溪市| 特克斯县| 晋中市| 铜川市| 余江县| 卓资县| 凤山市| 韩城市| 乌拉特中旗| 佛教| 吉首市| 大荔县| 布尔津县| 台安县| 宝清县| 西华县| 桐乡市| 阳江市| 南昌市| 宁夏| 磴口县| 全州县| 城固县| 洮南市| 双辽市| 抚宁县| 娱乐|