Announcement Announcement Module
Collapse
No announcement yet.
Spring + JPA (TopLink) Not generating DDLs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + JPA (TopLink) Not generating DDLs

    After 5 days of fighting with this I have finally decided to ask for help, no matter what I have attempted from insights I have gained reading this forum I can not solve this problem.

    My problem is fairly straightforward, when I deploy my application no DDL files are generated and no database
    tables are created (I commented out the code for file creation, however any solution that
    does one or the other is appreciated).

    Notes -
    I do receive logs such as the following:
    [TopLink Config]: 2011.07.18 10:40:30.872--ServerSession(15351295)--Thread(Thread[admin-thread-pool-4848(3),5,grizzly-kernel])--The alias name for the entity class [class com.mdb.beltapp.core.model.object.User] is being defaulted to: User.

    My environment is:
    Mac OS X 10.6.7
    Glassfish 3.1

    Here are my configuration files.

    1. spring-config.xml
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                               http://www.springframework.org/schema/tx
                               http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                               http://www.springframework.org/schema/context
                               http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <context:property-placeholder location="classpath:application.properties"/>
        <tx:annotation-driven transaction-manager="transactionManager"/>
        <bean id="userDao" class="com.mdb.beltapp.dao.UserDao">
            <property name="entityManagerFactory" ref="entityManagerFactory"/>
        </bean>

        <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
            <property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml"/>
        </bean>

        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
                    <property name="showSql" value="true"/>
                    <property name="generateDdl" value="false"/>
                    <property name="database" value="POSTGRESQL"/>
                    <property name="databasePlatform" value="oracle.toplink.essentials.platform.database.PostgreSQLPlatform"/>
                </bean>
            </property>
        </bean>

        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory"/>
        </bean>

        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="org.postgresql.Driver"/>
            <property name="url" value="jdbc:postgresql://localhost:5432/mdbbeltapp"/>
            <property name="username" value="postgres"/>
            <property name="password" value="xxxxxx"/>
        </bean>
    </beans>
    2. persistence.xml
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

        <persistence-unit name="MROSupplyPU" transaction-type="RESOURCE_LOCAL">
            <provider>oracle.toplink.essentials.PersistenceProvider</provider>
            <non-jta-data-source></non-jta-data-source>

            <class>com.mdb.beltapp.core.model.object.User</class>
            <class>com.mdb.beltapp.core.model.object.UserRole</class>
            <properties>
                <property name="toplink.jdbc.Schema" value="public"/>
                <property name="toplink.jdbc.driver" value="org.postgresql.Driver"/>
                <property name="toplink.jdbc.url" value="jdbc:postgresql://localhost:5432/mdbbeltapp"/>
                <property name="toplink.jdbc.user" value="postgres"/>
                <property name="toplink.jdbc.password" value="xxxxxx"/>
                <property name="toplink.ddl-generation" value="drop-and-create-tables"/>
                <property name="toplink.ddl-generation.output-mode" value="database"/>   
                <!--
                <property name="toplink.ddl-generation.output-mode" value="sql-script"/>
                <property name="toplink.create-ddl-jdbc-file-name" value="create.sql"/>
                <property name="toplink.drop-ddl-jdbc-file-name" value="drop.sql"/>
                <property name="toplink.application-location" value="/Users/ddurst/IdeaProjects/MDBBeltApp-1.0/ddl"/>
                -->
                <property name="toplink.cache.size.default" value="5000"/>
                <property name="toplink.weaving" value="false"/>
                <property name="oracle.toplink.essentials.config.TargetDatabase" value="PostgreSQL"/>
                <property name="toplink.logging.level" value="finest"/>
                <property name="toplink.logging.logger" value="DefaultLogger"/>
            </properties>
        </persistence-unit>
    </persistence>

  • #2
    Glassfish 3.1 ships with EclipseLink 2.2 not TopLink Essentials. Unless you have specifically setup TopLink Essentials you should be using the EclipseLink properties.
    ie. : <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

    Comment

    Working...
    X