Eclipselink,@ OneToMany不适用于模式生成= drop-and-create

时间:2015-06-20 19:28:29

标签: java jpa schema eclipselink one-to-many

经过大量研究,我终于找到了失败的原因。

使用Eclipselink时,@OneToMany包含时persistence.xml无效(返回null):

(适用滴和创建)

<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>

但它适用于此:

(无)

<property name="javax.persistence.schema-generation.database.action" value="none"/>

以下是文件persistence.xml的所有代码:

    <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" >
  <persistence-unit name="XXXX-ejbPU" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/xxxxDatasource</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>ALL</shared-cache-mode>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
      <property name="eclipselink.target-database" value="MySQL"/>
      <property name="eclipselink.logging.level.sql" value="OFF"/>
      <property name="eclipselink.logging.parameters" value="true"/>
      <property name="eclipselink.persistence-context.flush-mode" value="AUTO"/>
    </properties>
  </persistence-unit>
</persistence>

P.S:@OneToMany可以正常使用Hibernate。

有没有人能解决这个问题?

0 个答案:

没有答案