Ale*_*uch 8 java jpa openjpa openejb apache-tomee
摘要
我正在尝试运行Java Web应用程序JPA 2.0示例.该示例应用程序被写入到运行Glassfish,使用EclipseLink作为JPA提供商.我想将其转换为运行在TomEE与OpenJPA作为JPA提供者,但我不能为起床,并与正在运行的任何详细的教程OpenJPA.
问题
我很难转换persistence.xml到工作OpenJPA而不是EclipseLink.更具体地说,给定的persistence.xml未指定:
Entity类.这些必要吗?也:
细节
以下是EclipseLink persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="order" transaction-type="JTA">
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode"
value="both" />
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
我有以下Entity课程:
order.entity.LineItemorder.entity.LineItemKeyorder.entity.Orderorder.entity.Partorder.entity.PartKeyorder.entity.Vendororder.entity.VendorPart题
如果您添加openjpa.jdbc.SynchronizeMappings如下所示的属性,OpenJPA将自动创建所有表,所有主键和所有外键完全匹配您的对象
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
Run Code Online (Sandbox Code Playgroud)
或者,您可以通过添加EclipseLink jar来在TomEE中使用EclipseLink <CATALINA_HOME>/lib/
在这里引用Common PersistenceProvider属性
| 归档时间: |
|
| 查看次数: |
8556 次 |
| 最近记录: |