【发布时间】:2014-04-04 06:37:02
【问题描述】:
我想在我的应用引擎数据存储应用引擎上执行IN 查询。在这里我遇到了奇怪的问题。问题是,当我将单个值传递给IN 标准时,它会返回正确的记录,但是当我将多个值传递给IN 标准时,它会返回null 响应。如果我在服务器上执行相同的查询,那么它会返回正确的输出。我不知道我的代码有什么问题。我在我的 android 客户端中使用 endpoint 类,并且我正在将值从 android 客户端传递到应用程序引擎后端。请帮我解决这个问题。谢谢。
更新:
我更改了我的代码,如下所示,现在我将 ArrayList 作为参数传递并使其正常工作。
代码:
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "getUserFavouriteFeed", httpMethod = HttpMethod.GET, path = "userfeedmasterendpoint/userName_fk1")
public CollectionResponse<tableFresopnce> getUserFavouriteFeed(
@Named("uname") ArrayList<String> uname,
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<UserFeedMaster> execute = null;
try {
mgr = getEntityManager();
Query query = mgr
.createQuery("select f from tableF f where f.isDeleted=:delStatus and f.userName in (:uname)");
query.setParameter("uname", uname);
query.setParameter("delStatus", false);
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}
execute = (List<UserFeedMaster>) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();
// Tight loop for fetching all entities from datastore and
// accomodate
// for lazy fetch.
for (UserFeedMaster obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<tableFresopnce> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
【问题讨论】:
标签: android google-app-engine jpa google-cloud-datastore google-cloud-endpoints