NativeQueryに関する議論 パート2 in TheServerSide.COM

ますます白熱する議論で、ものすごいdb4oのダウンロードになってきました!やはりTSSでのバトルは破壊力抜群です。ぜひご覧ください。

さて、その中でソフトウェア設計の役員であるCarlから、ネイティブクエリの応用サンプルが提示されておりますので、ご紹介します。

Here are two very simple features that you will find hard to implement in an SQL query:

(1) Multiple exit points, using a guard-pattern in this case.
(2) Local mutable variable in a query.

List products = db.query(new Predicate (){
public boolean match(Product product){
if(product.getLicense() == Licenses.GPL){
return true;
}
Float price = product.getPrice();
Vendor vendor = product.getVendor();
return price > 10
&& price < 100
&& vendor.getName().startsWith("d")
&& vendor.getCountry() == Countries.USA;
}
});

ところで、TSSのこのスレッドに私も先ほど参戦してみました;)


db4o Japanese Community
http://www.db4o.com/japan/
japan@db4o.com