使用JDO查询时,要为查询涉及到的字段配置索引。否则报com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found..
在war/WEB-INF/下新建datastore-indexes-auto.xml
内容类似如下:
说明:
1、FanOrder为实体类
2、property为查询时使用到的属性
在war/WEB-INF/下新建datastore-indexes-auto.xml
内容类似如下:
<datastore-indexes>
<datastore-index kind="FanOrder" ancestor="false" source="auto">
<property name="username" direction="asc"/>
<property name="state" direction="asc"/>
<property name="orderDate" direction="desc"/>
</datastore-index>
</datastore-indexes>说明:
1、FanOrder为实体类
2、property为查询时使用到的属性
本文介绍了解决使用JDO进行数据查询时遇到的DatastoreNeedIndexException的方法。通过在项目中配置datastore-indexes-auto.xml文件并定义具体的实体类和属性索引来避免异常发生。
3937

被折叠的 条评论
为什么被折叠?



