我正在嘗試使用JPA,Google Cloud SQL和本地MySQL數據庫來開發Google App Engine應用程序。我正在使用GAE eclipse插件。我已經註冊了Google雲SQL實例。在項目上配置應用程序引擎設置以使用Google Cloud SQL,併爲本地MySQL數據庫和雲SQL實例提供連接信息。GAE谷歌雲數據庫JPA本地MySQL結果爲空
數據核心增強器選擇我的57個類,我看到成功優化類的日誌。我在Eclipse中運行我的應用程序,dev環境成功啓動,我可以通過瀏覽器訪問我的應用程序。
問題是無法從JPA調用中檢索數據庫中的數據。我在應用程序輸出中看不到任何錯誤。我運行調試器並且JPA調用成功運行,而不會在我的應用程序源代碼中拋出異常。我從檢索中得到一個空列表。
我不確定這裏要做什麼。我在網上進行了相當長時間的研究,我無法弄清楚我做錯了什麼。當我沒有例外或使用某些東西時,很難追查到什麼東西。
我的猜測是有一些失敗,但錯誤可能被吞噬或可能是一個限制。我也嘗試通過使用條件構建器更改JPA調用,然後直接使用JPQL。仍然得到相同的結果。
檢查參數到dev服務器,我看到從我爲本地mysql服務器輸入的配置中使用的參數。是否有可能以某種方式忽略這些論點?
任何幫助,將不勝感激。
的persistence.xml - (只有2類用於測試)
<persistence-unit name="iberis-jpa">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>com.bizznetworxonline.iberis.core.SystemArea</class>
<class>com.bizznetworxonline.iberis.core.SystemUnit</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
JPQL呼叫:
public List<?> findAll(Class<?> entityClass)
{
EntityManager em = JPA_EMF.get().createEntityManager();
javax.persistence.Query q = em.createQuery("SELECT o FROM " + entityClass.getSimpleName() + " o",entityClass);
List<?> results = q.getResultList();
return results;
}
從控制檯輸出:
Mar 30, 2013 9:49:06 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/appengine-web.xml
Mar 30, 2013 9:49:06 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/web.xml
Mar 30, 2013 9:49:06 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value '/home/user/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/com.google.appengine.eclipse.sdkbundle_1.7.6/appengine-java-sdk-1.7.6/config/sdk/logging.properties' with value 'WEB-INF/logging.properties' from '/home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/appengine-web.xml'
Mar 30, 2013 9:49:07 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Mar 30, 2013 9:49:07 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Mar 30, 2013 9:49:10 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.12 (20120814-1522) for context ''
Mar 30, 2013 9:49:13 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
Mar 30, 2013 9:49:21 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces 3.5
Mar 30, 2013 9:49:21 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces Extensions 0.6.3
Mar 30, 2013 9:49:22 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started [email protected]:8888
Mar 30, 2013 9:49:22 PM com.google.appengine.tools.development.AbstractServer startup
INFO: Server default is running at http://localhost:8888/
Mar 30, 2013 9:49:22 PM com.google.appengine.tools.development.AbstractServer startup
INFO: The admin console is running at http://localhost:8888/_ah/admin
Mar 30, 2013 9:49:22 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: Dev App Server is now running
Mar 30, 2013 9:49:35 PM com.google.appengine.api.datastore.dev.LocalDatastoreService init
INFO: Local Datastore initialized:
Type: High Replication
Storage: /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/appengine-generated/local_db.bin
Mar 30, 2013 9:49:35 PM com.google.appengine.api.datastore.dev.LocalDatastoreService load
INFO: The backing store, /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB- INF/appengine-generated/local_db.bin, does not exist. It will be created.
Mar 30, 2013 9:49:37 PM com.google.apphosting.utils.jetty.JettyLogger warn
我已經改變了我的代碼來使用jpql,就像我上面發佈的那樣。它不起作用。我的控制器是一個簡單的會話託管bean,它所做的只是調用該函數來獲取數據。我認爲問題不在控制器中。我用於開發的虛擬機在Ubuntu 12.04上稍微老一點,它已經對基本操作系統和Eclipse進行了幾次升級。我的猜測是,在我的環境中有些東西被嚴重地弄丟了。因爲,沒有其他人有這個問題。奇怪,我沒有得到一個單一的錯誤消息。 –
我將嘗試在新的虛擬機中安裝新的全新環境,我會在那裏測試以查看會發生什麼。希望它能起作用。 –