2013-06-06 2 views
0

엔티티의 엔드 포인트 클래스에 새 메소드를 추가하려고합니다. 그러나 엔드 포인트 클라이언트 라이브러리를 생성하기 위해 앱 엔진 프로젝트를 마우스 오른쪽 버튼으로 클릭하면 이클립스 엔드 포인트 라이브러리 생성 오류가 발생했다는 메시지가 표시됩니다. 아래는 엔티티의 엔드 포인트 라이브러리에 추가 한 코드입니다. 누구든지 여기서 무엇이 잘못 되었는가를 제안 할 수 있습니까?엔드 포인트 클라이언트 라이브러리 생성 오류

  @SuppressWarnings("unchecked") 
    public List<UserTable> getUserTableByEmail(String email) { 
     EntityManager mgr = null; 
     List<UserTable> execute = null; 
     try { 
      mgr = getEntityManager(); 
      Query query = mgr.createQuery("select n from UserTable n where n.emailAddress = :emailAddress"); 
      query.setParameter("emailAddress", email); 
      execute = (List<UserTable>) query.getResultList(); 
     } finally { 
      mgr.close(); 
     } 
     return execute; 
    } 

답변

0

내 사용자 지정 쿼리와 함께 내 자신의 끝점 메서드를 추가하기위한 아래 작업 코드가 업데이트되었습니다.

@SuppressWarnings({ "unchecked", "unused" }) 
@ApiMethod(name = "getUserTableByEmail") 
public CollectionResponse<UserTable> getUserTableByEmail(
     @Nullable @Named("cursor") String cursorString, 
     @Nullable @Named("limit") Integer limit, 
     @Named ("emailAddres") String email) { 

    EntityManager mgr = null; 
    Cursor cursor = null; 
    List<UserTable> execute = null; 

    try { 
     mgr = getEntityManager(); 
     Query query = mgr.createQuery("select n from UserTable n where n.emailAddress = '"+email+"'"); 
     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<UserTable>) 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 (UserTable obj : execute) 
      ; 
    } finally { 
     mgr.close(); 
    } 

    return CollectionResponse.<UserTable> builder().setItems(execute) 
      .setNextPageToken(cursorString).build(); 
} 
관련 문제