Results 1 to 7 of 7

Thread: (not) drop tables when running app?

  1. #1
    Join Date
    May 2008
    Location
    Silicon Valley, CA
    Posts
    139

    Default (not) drop tables when running app?

    I've used roo to define database entities, and use the generated views/forms to insert data into the database.
    I have configured to use mysql rather than the in-mem hsqldb:
    Code:
    persistence setup  --provider HIBERNATE  --database MYSQL
    And indeed the data is correctly persisted.

    But when I re-run the app/tomcat (from within STS) existing tables are dropped.

    Can someone point me to the config/switch that makes STS or whatever [not] delete the data?

  2. #2
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Lightbulb It's an FAQ

    Please see this thread and others.
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  3. #3
    Join Date
    May 2008
    Location
    Silicon Valley, CA
    Posts
    139

    Thumbs up

    Thank you.

    I knew it should be easy, but didn't know what to search for.

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    I'll get this added to the reference guide (tracked as https://jira.springsource.org/browse/ROO-627).
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  5. #5
    Join Date
    May 2008
    Location
    Silicon Valley, CA
    Posts
    139

    Default

    And a comment in the persistence.xml might be helpful.
    I believe many users will find their way to this config file, so it's is a good place to put the info or a link:

    Code:
        <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    	    <!-- value="create" to get new database each run; value="update" to use existing database: see ... -->
                <property name="hibernate.hbm2ddl.auto" value="update"/>
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            </properties>
        </persistence-unit>

  6. #6
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Thumbs up

    Quote Originally Posted by Ben Alex View Post
    I'll get this added to the reference guide (tracked as https://jira.springsource.org/browse/ROO-627).
    Fixed that for ya.

    P.S. Jack's idea of putting a comment in persistence.xml is a great one.
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  7. #7
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    ROO-627 is now completed. Both the persistence.xml suggestion and reference guide section have been added.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

Posting Permissions

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