我正在使用 AppEngine,我想查询数据实体:
- 布尔数据“可选”为 False。
- Date 'registrationTimestamp' 的升序。
我的代码:
Query query = pm.newQuery(DeviceInfo.class);
query.setFilter("optional == False");
query.setOrdering("registrationTimestamp asc");
List<DeviceInfo> datas = (List<DeviceInfo>)query.execute();
当我看到数据时,有“可选”为 True 的数据。我想过滤掉“可选”为真的条目。似乎 setFilter("optional == False") 不起作用。
如何执行我想要的查询?
编辑
我得到了 DataNucleus 建议的 DEBUG 级别的日志。
org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints: Bundle "org.datanucleus.jpa" has an optional dependency to "org.datanucleus.enhancer" but it cannot be resolved
org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints: Bundle "org.datanucleus" has an optional dependency to "org.eclipse.equinox.registry" but it cannot be resolved
org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints: Bundle "org.datanucleus" has an optional dependency to "org.eclipse.core.runtime" but it cannot be resolved
org.datanucleus.PersistenceConfiguration setProperty: Property datanucleus.rdbms.sql.allowAllSQLStatements unknown - will be ignored
org.datanucleus.PersistenceConfiguration setProperty: Property datanucleus.rdbms.stringDefaultLength unknown - will be ignored
org.datanucleus.PersistenceConfiguration setProperty: Property datanucleus.appengine.autoCreateDatastoreTxns unknown - will be ignored
org.datanucleus.ObjectManagerFactoryImpl logConfiguration: ================= Persistence Configuration ===============
org.datanucleus.ObjectManagerFactoryImpl logConfiguration: DataNucleus Persistence Factory - Vendor: "DataNucleus" Version: "1.1.5"
org.datanucleus.ObjectManagerFactoryImpl logConfiguration: DataNucleus Persistence Factory initialised for datastore URL="appengine" driver="" userName=""
org.datanucleus.ObjectManagerFactoryImpl logConfiguration: ===========================================================
org.datanucleus.PersistenceConfiguration setProperty: Property datanucleus.query.cached unknown - will be ignored
org.datanucleus.jdo.metadata.JDOMetaDataManager <init>: Registering listener for metadata initialisation
org.datanucleus.jdo.metadata.JDOAnnotationReader processClassAnnotations: Class "net.xxxxxxxxx.xxxxxxx.server.DeviceInfo" has been specified with JDO annotations so using those.
org.datanucleus.store.appengine.MetaDataValidator validate: Performing appengine-specific metadata validation for net.xxxxxxxxx.xxxxxx.server.DeviceInfo
org.datanucleus.store.appengine.MetaDataValidator validate: Finished performing appengine-specific metadata validation for net.xxxxxxxxx.xxxxxx.server.DeviceInfo
org.datanucleus.store.StoreDataManager registerStoreData: Managing Persistence of Class : net.xxxxxxxxx.xxxxxxx.server.DeviceInfo [Table : <class name="DeviceInfo"
identity-type="application"
objectid-class="javax.jdo.identity.ObjectIdentity"
persistence-modifier="persistence-capable"
>
<inheritance strategy="new-table">
</inheritance>
<field name="deviceRegistrationID"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
<field name="gcm"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
<field name="key"
persistence-modifier="persistent"
primary-key="true"
null-value="none"
default-fetch-group="true"
embedded="false"
unique="false">
</field>
<field name="optional"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
<field name="registrationTimestamp"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
</class>
, InheritanceStrategy : new-table]
org.datanucleus.store.StoreDataManager registerStoreData: Managing Persistence of Class : net.xxxxxxxxx.xxxxxxx.server.DeviceInfo [Table : <class name="DeviceInfo"
identity-type="application"
objectid-class="javax.jdo.identity.ObjectIdentity"
persistence-modifier="persistence-capable"
>
<inheritance strategy="new-table">
</inheritance>
<field name="deviceRegistrationID"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
<field name="gcm"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
<field name="key"
persistence-modifier="persistent"
primary-key="true"
null-value="none"
default-fetch-group="true"
embedded="false"
unique="false">
</field>
<field name="optional"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
<field name="registrationTimestamp"
persistence-modifier="persistent"
null-value="none"
default-fetch-group="true"
embedded="true"
unique="false">
</field>
</class>
, InheritanceStrategy : new-table]
org.datanucleus.jdo.metadata.JDOMetaDataManager$MetaDataRegisterClassListener registerClass: Listener found initialisation for persistable class net.xxxxxxxxx.xxxxxxx.server.DeviceInfo
com.google.appengine.api.datastore.QueryResultsSourceImpl logChunkSizeWarning: This query does not have a chunk size set in FetchOptions and has returned over 1000 results. If result sets of this size are common for this query, consider setting a chunk size to improve performance.
To disable this warning set the following system property in appengine-web.xml (the value of the property doesn't matter): 'appengine.datastore.disableChunkSizeWarning'