Ive는 천 가지를 시도했습니다. 지금 당장은 내가 무엇을 쿼리 할 수있는 유일한 방법은 전체 목록을 가져 와서 그런 식으로 살펴 보는 것입니다! 많은 시간이 걸립니다. 예를 들어 Google 애플리케이션 엔진에서 무언가를 쿼리하려면 어떻게합니까? 예를 들어 100 표 이상인 항목 만 가져옵니다.android를 사용하는 Google 애플리케이션 엔진의 엔티티 검색어
임 예에서 틱택 예 https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-java 및 https://developers.google.com/eclipse/docs/endpoints-addentities 다음 난 그냥 따옴표 노트 투입합니다.
을 Heres이 비동기 작업과로드 긴
다음protected CollectionResponseQuotes doInBackground(Context... contexts) {
Quotesendpoint.Builder endpointBuilder = new Quotesendpoint.Builder(
AndroidHttp.newCompatibleTransport(),
new JacksonFactory(),
new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) { }
});
Quotesendpoint endpoint = CloudEndpointUtils.updateBuilder(
endpointBuilder).build();
try {
quotes = endpoint.listquotes().execute();
for (Quotes quote : quotes.getItems()) {
if (quote.getVotes() > 3) {
quoteList.add(quote);
}
}
에 소요 각각의 하나 인 엔티티 를 받고 메신저 구글의 앱 엔진에서 생성 된 코드입니다 방법에 대한 예를 들어, 내 현재 코드 엔드 포인트를 만들었습니다. 그것은 어쨌든 질의를하는 것처럼 보이지만 그것을 이해할 수는 없습니다. 두 가지 프로젝트입니다.
@Api(name = "quotesendpoint", namespace = @ApiNamespace(ownerDomain = "projectquotes.com", ownerName = "projectquotes.com", packagePath = ""))
public class quotesEndpoint {
/**
* This method lists all the entities inserted in datastore.
* It uses HTTP GET method and paging support.
*
* @return A CollectionResponse class containing the list of all entities
* persisted and a cursor to the next page.
*/
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listquotes")
public CollectionResponse<quotes> listquotes(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<quotes> execute = null;
try {
mgr = getEntityManager();
Query query = mgr.createQuery("select from quotes as quotes");
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<quotes>) 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 (quotes obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<quotes> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
/**
* This method gets the entity having primary key id. It uses HTTP GET method.
*
* @param id the primary key of the java bean.
* @return The entity with primary key id.
*/
@ApiMethod(name = "getquotes")
public quotes getquotes(@Named("id") String id) {
EntityManager mgr = getEntityManager();
quotes quotes = null;
try {
quotes = mgr.find(quotes.class, id);
} finally {
mgr.close();
}
return quotes;
}
사용자 커서를 사용해 보았지만 어떻게 작동하는지 이제 알았습니다. 시도 했어
Cursor cursor = db.rawQuery("select * from Votes WHERE Votes >" + 250 , null);
quotes = endpoint.listquotes().setCursor(cursor).execute();
응답 해 주셔서 감사합니다! 이런 뜻인가요? 커서가 어떻게 작동하는지 예제를 보여 주시겠습니까? 필자는 이것을 다음과 같이 시도했다 – NightSkyCode
커서 cursor = db.rawQuery ("select * from Votes WHERE Votes>"+ 250, null); quotes = endpoint.listquotes(). setCursor (cursor) .execute(); – NightSkyCode
내가 필요하지 않았기 때문에 정의 된 데이터베이스가 없다 – NightSkyCode