내 엔티티에서 선택한 필드를 가져 오기 위해 엔드 포인트 클래스에서 표준 선택 쿼리를 수정하려고합니다. 그러나 쿼리를 변경 한 후에도 내 쿼리 결과가 모든 필드를 가져 오는 것으로 나타났습니다. 아래 코드는 내 자신을 추가하도록 쿼리가 업데이트되었음을 나타냅니다. 기본적으로 엔티티의 일부 속성 만 가져 오는 대신 네트워크 데이터 트랜잭션 볼륨을 줄이기 위해 모든 속성을 가져 오는 쿼리를 작성하려고합니다. 어떤 도움을 주셔서 감사합니다. GAE 데이터 저장소에 대한엔티티 포인트 클래스의 엔티티에서 몇 가지 속성을 선택하는 중
//QUERY MODIFIED IN THIS METHOD
/**
* 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 = "listQuizTable")
public CollectionResponse<QuizTable> listQuizTable(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<QuizTable> execute = null;
try {
mgr = getEntityManager();
//Query query = mgr.createQuery("select from QuizTable as QuizTable");
Query query = mgr.createQuery("select n.quizKey, n.quizDesc, n.uploadDate from QuizTable n");
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<QuizTable>) 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 (QuizTable obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<QuizTable> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
나는 누군가이 쿼리에 대해 투표 한 이유가 무엇인지 궁금합니다. 내가 작성하는대로 Google 앱 엔진과 엔드 포인트는 계속 진화하고 있습니다. Google에는이 문서도 많지 않습니다. stackkoverflow에 이러한 쿼리를 게시하면 downvoting이 발생하면 매우 바람직하지 않습니다. 나는 앱 엔진 백엔드 설정을 시작한 이래로 지난 1 개월 동안 내가 배운 것을 토대로 다른 사용자를 돕기 위해 많은 질문에 답을하고있었습니다. – user1938357