2

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?

Skizzo
  • 2,883
  • 8
  • 52
  • 99
  • Are the SQL credentials right? Do you get any errors? eclipselink.ddl-generation looks fine – David Apr 09 '14 at 13:50
  • I don't get any errors, the credential appear to be correct – Skizzo Apr 09 '14 at 13:55
  • Turn on eclipselink logging and see what it is trying to do. You are also using 'database' but specifying an DDl file. If you want a DDL file created as well, you should use 'both'. The file and tables should be created when the EntityManager is first deployed. If you are not accessing an EM, try adding the eclipselink.deploy-on-startup property: http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_deploy_on_startup.htm – Chris Apr 09 '14 at 15:02
  • 1
    Maybe the problem is that myUnit is member of a composite persistence unit beacause if i use it in a standalone way everything works – Skizzo Apr 10 '14 at 07:36

0 Answers0