0
我必須在objectdb中實現一個查詢,而且幾乎沒有任何想法。在objectdb中的查詢
的問題是編寫一個查詢其
Returns the collection of all laptops each of which has at least one
other laptop preinstalled with the same processor.
我的筆記本電腦類是
public class Laptop {
String modelName; // key
int price; // in dollars
boolean hasHDScreen; // has a HD Screen ?
int hardDriveCapacity; // in GB
Processor processor; // the preinstalled processor
Memory memory; // the preinstalled memory
Company madeBy; // the inverse of company.makeLaptops
}
和我的處理器類是
public class Processor {
String modelName; // key
float clockSpeed; // in gigahertz (GHz)
Company madeBy; // the inverse of Company.makeProcessors
}
而且我的函數定義看起來像下面
public static Collection<Laptop> sameProcessor(Query q) {
/* Returns the collection of all laptops each of which has at least one
* other laptop preinstalled with the same processor.
*/
q.setClass(Laptop.class);
q.setFilter("this.processor == ");
}
我該如何實現它? SQL也可以。
謝謝
你使用休眠? – ant
@ant:沒有,只是JDOQL查詢 –
@ant:但在hibernate中的查詢也可以很方便。因爲那樣我就可以嘗試將它轉換成JAVA,並因此轉換成ObjectDb查詢語言 –