1
我正在構建一個與Google Appengine數據存儲集成而不使用JDO的android應用程序。爲什麼getEntityManager()未定義? 「無法解析方法getEntityManager」
我正在嘗試構建一個允許我訪問數據存儲中的數據的端點。我寫功能如下,但是,我有一個奇怪的問題,儘管把這個代碼到端點的java類...
我得到的是Cannot Resolve Method getEntityManager()
在,我在網上看到的每一個例子中的錯誤,它都調用這個函數。 - 所以必須有辦法讓它工作,否則我必須做一些愚蠢的事情。
我錯過了什麼?我怎樣才能解決這個
@Api(name = "getPostsApi", version = "v1", namespace = @ApiNamespace(ownerDomain = "endpoints.myModule.myCo.com",
ownerName = "endpoints.myModule.myCo.com", packagePath=""))
public class GetPostsEndpoint {
/**
* 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 = "GetPostsEndpoint")
public CollectionResponse<NewPostBean> listStuff(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<NewPostBean> execute = null;
try {
mgr = getEntityManager(); // <---- Breaks on this line
//Query query = mgr.createQuery("select from Stuff as Stuff");
// limit =1;
//execute = (List<NewPostBean>) query.getResultList();
//cursor = JPACursorHelper.getCursor(execute);
//for (NewPostBean obj : execute)
// ;
//} finally {
// mgr.close();
//}
return CollectionResponse.<NewPostBean>builder().setItems(execute).setNextPageToken(cursorString).build();
}
}
我在網上學習一個教程!我想他們離開了那部分。另外,我添加了一個變量和一個函數來返回EntityManager而不是EntityManagerFactory。非常感謝 – user198923 2014-10-10 22:12:54
非常歡迎:)令人驚訝的教程留下了這樣一個重要的部分:P – Patrice 2014-10-10 22:13:35