0
我使用JPA工具從@Entity
類生成表。當設置爲RESOURCE_LOCAL
它工作得很好。從實體生成表 - JTA
javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/mysqltest].
Internal Exception: javax.naming.NamingException: Lookup failed for 'jdbc/mysqltest' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
...
所以每次我要修改表結構,我需要改回
:但是之後我設置了一個GlassFish服務器上的數據源,並相應修改了persistence.xml
,它具有異常停止
從
<persistence ...>
<persistence-unit name="Foo" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/footest</jta-data-source>
<properties>
<property name="eclipselink.target-server" value="None"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
到
<persistence ...>
<persistence-unit name="Foo" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="eclipselink.target-server" value="None"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
有沒有辦法使用表生成工具而不需要觸摸配置?
感謝您的回覆。數據源正在工作,我可以使用實體管理器並返回數據庫中的結果。我也嘗試了你的建議。但是在生成表的過程中的異常仍然是相同的。 – Swato 2012-04-26 22:05:24