EclipseLink doesn't create tables

2019-04-14 21:59发布

I'm developing an application with eclipseLink and Spring. For now I'm using h2 like database. My trouble is that eclipseLink is not able to create tables.

This is my configuration.

Persistence.xml:

<persistence>

    <persistence-unit name="myUnit">

    //some classes definition

     <properties>

     <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
     <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:C:\Users\user\Desktop\myFolder\test.db" />
     <property name="javax.persistence.jdbc.user" value="sa" />
     <property name="javax.persistence.jdbc.password" value="" />
     <property name="eclipselink.ddl-generation" value="create-tables" />
     <property name="eclipselink.composite-unit.member" value="true"/>
     <property name="eclipselink.target-database"      value="org.eclipse.persistence.platform.database.H2Platform"/>
     <property name="eclipselink.ddl-generation.output-mode" value="database" />
     <property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql"/>

      </properties>

    </persistence-unit>



</persistence>

spring-context.xml

<beans>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
        p:entityManagerFactory-ref="emf">
        <property name="persistenceUnitName" value="myUnit" />
    </bean>

    <bean id="eclipseLinkJpaVendorAdapter"
        class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
    </bean>


    <tx:annotation-driven />

    <bean id="emf"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        p:jpaVendorAdapter-ref="eclipseLinkJpaVendorAdapter"
        p:persistenceUnitName="myUnit">
        <property name="jpaPropertyMap">
            <map>
                <entry key="eclipselink.cache.shared.default" value="false" />
                <entry key="eclipselink.weaving" value="false" />
            </map>
        </property>
        <property name="loadTimeWeaver">
            <bean
                class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
        </property>
    </bean>

</beans>

Moreover i find the file create.sql empty!!!

Where am I doing wrong?

0条回答
登录 后发表回答