0
我正在嘗試爲某些基本的Google App Engine服務編寫Spring配置。特別是對於EntityManagerFactory和Entity Manager。使用Spring 3.0的Google App Engine實體管理器配置
要創建Java代碼中的EntityManagerFactory:
EntityManagerFactory emfInstance = javax.persistence.Persistence
.createEntityManagerFactory("transactions-optional");
因爲這也是我翻譯:
<bean id="entityManagerFactory" class="javax.persistence.Persistence"
factory-method="createEntityManagerFactory" scope="singleton">
<constructor-arg value="transactions-optional"/>
</bean>
而且每次我需要一個EntityManager
EntityManager em = emfInstance.get().createEntityManager();
但我不不知道如何將工廠方法應用到先前創建的工廠。
<bean id="entityManagerProto"
factory-method="createEntityManager" scope="prototype"/>
任何人都知道嗎?謝謝。
謝謝你,但LocalEntityManagerFactoryBean負責一注云:*僅使用簡單的部署環境,如獨立的應用程序和集成測試此選項* – stivlo
@stivlo:'LocalEntityManagerFactoryBean'不完全一樣的,你做手工的東西。春天的傢伙意味着在生產環境中,你可能想要以更復雜的方式獲得'EntityManagerFactory'(由LocalContainerEntityManagerFactoryBean提供),但它肯定不適用於GAE。 – axtavt
啊,我明白了...我會試試的。 – stivlo