亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2442 | 回復: 0
打印 上一主題 下一主題

DB4O學習(三)對象的查詢 [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-01-23 10:22 |只看該作者 |倒序瀏覽

1.三種查詢方式
  (1)QBE--只能精確查找
  (2)Simple Object Data Access(SODA)--DB4O的一套查詢API
  (3)Native Queries(NQ)--調整查詢以達到更高的查詢速度

2.三種查詢方式的對比


3.QBE的幾種方式:
(1)通過構造器指定參數(shù)
Person template = new Person();
template.setName("Ben");
ObjectSet res = db.get(template);
(2)通過setter指定參數(shù)
Person template = new Person();
template.setName("Ben");
template.setAge(42);
ObjectSet res = db.get(template);
(3)其他方法
Person template = new Person(null, 82);   // match age only Person template = new Person("Ben", 0);   // match name only
Person template = new Person(null, 0);    // ensure an empty template

(4)指定類型
ObjectSet res = db.get(Person.class);   // JAVA
(5)獲取全部類型
ObjectSet res = db.get(null);   // JAVA

4.QBE的幾個問題
• You can’t use the values that are defined to mean “empty” as constraints. Fields specified
as null, 0, or "" (empty string) are treated as unconstrained, which could be a problem
in some cases. For example, what if you actually want to find Person objects with _age
equal to 0? You can’t when using QBE.
如果想查找age為0的person則不能用QBE.
• You might run into problems if your classes initialize fields when they are declared. For
example, what if the Person class initializes the attribute string _name = "Joe"? In that
case, a query that uses the default constructor to create an “empty” template will only
return “Joe” objects. To get a truly empty template, you would have to explicitly set the
_name attribute to null.
對于類內部初始化的情況要特別注意初始化的值。


本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u3/93829/showart_2158286.html
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP