Results 1 to 2 of 2

Thread: How to forward engineer Schema in Roo?

  1. #1
    Join Date
    Oct 2011
    Posts
    7

    Default How to forward engineer Schema in Roo?

    Hi,

    In Grails there is a feature which helps in Forward Engineering Schema for Domain Model Objects. I saw DBRE add on which helps in keeping Domain Model and Database Schema in Sync but does not tell you how to forward engineer the DB Schema from Domain Model?

    Can someone please tell me how to forward engineer DB Schema in Roo?

    Regards,
    Anand

  2. #2
    Join Date
    Oct 2011
    Posts
    7

    Default

    Hi,

    I have figured out a solution for this. One can use hibernate ddl plugin for this, may be the inventors of Roo thought there are such plugins available for Schema forward generation so why waste time re inventing the wheel so they focused on the Spring DBRE plugin which syncs up the Object model with Data model.

    To describe the solution add these snippets to your pom.xml

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
    <components>
    <component>
    <name>hbm2ddl</name>
    <implementation>jpaconfiguration</implementation>
    </component>
    </components>
    <componentProperties>
    <persistenceunit>persistenceUnit</persistenceunit>
    <outputfilename>schema.ddl</outputfilename>
    <drop>true</drop>
    <create>true</create>
    <export>false</export>
    <format>true</format>
    </componentProperties>
    </configuration>
    <dependencies>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.9</version>
    </dependency>
    </dependencies>
    </plugin>

    The above pom is for schema generation in my sql database you can change it to the DB of your liking.

    Run the MVN command:

    mvn hibernate3:hbm2ddl

    The ddl can be seen in target/hibernate3/sql/schema.ddl

    Incase you want to change it to some other Database modify your persistence.xml

    <property name="hibernate.dialect" value="Provide your hibernate dialect for DB" />

    Regards,
    Anand

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •