我內嵌入另一個類(帳戶)定義的類(StudentProfile)用戶。 Google Datastore默認索引Embedded類的屬性,我想取消索引Embedded Class(StudentProfile)中的許多屬性。Unindexing嵌入式類屬性使用@Embedded和@EmbeddedOnly JDO註解使用JDO(APP-發動機)
我已經嘗試在帳戶類中使用'@Extension(vendorName =「datanucleus」,key =「gae.unindexed」,value =「true」)',其中我聲明瞭StudentProfile Attribute以及各種StudentProfile類本身的屬性。即使在此之後,我也可以通過studentAttribute.shortName(我註釋爲未索引的字段)進行過濾。由於Google Datastore文檔中說未加索引的字段不能用作過濾器,我認爲這意味着無用的努力是徒勞的。
我相信這是一個@Unindex註釋在客觀化,有沒有JDO等效?
我也試圖與unindexing在Account類普通屬性(使用JDO擴展)進行實驗,它的工作原理(即返回空當我試圖通過屬性進行篩選)。以下是每個班級的相關代碼。任何幫助都大大提升!謝謝!
@PersistenceCapable
public class Account {
// primary key and other attributes...
// the embedded class with renaming for the clashing fields
@Persistent(dependent="true", defaultFetchGroup="false")
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
@Embedded(members = {
@Persistent(name="shortName", [email protected](name="shortName"), [email protected](vendorName="datanucleus", key="gae.unindexed", value="true")),
@Persistent(name="email", [email protected](name="personalEmail")),
@Persistent(name="institute", [email protected](name="originalInstitute"))
})
private StudentProfile studentProfile;
}
// the embeddedOnly class
@PersistenceCapable(embeddedOnly="true")
public class StudentProfile {
// other attributes...
// the filter attribute I used for querying
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private String shortName;
}
public StudentProfileAttributes getStudentProfile(String shortName) {
Query q = getPM().newQuery(Account.class);
q.declareParameters("String shortNameParam");
q.setFilter("studentProfile.shortName == shortNameParam");
// the following execution works and a result is returned!
@SuppressWarnings("unchecked")
List<Account> accountsList = (List<Account>) q.execute(shortName);
}
嗨!我已經閱讀了該博客,並嘗試了向該字段添加@Extension(vendorName =「datanucleus」,key =「gae.unindexed」,value =「true」)的建議解決方案。但它不工作:-(我失去了一些東西在這裏?謝謝! – thyageshm
如果有什麼「不工作」,那麼建議你看看日誌,並制定出* *爲什麼它不工作。 –