Announcement Announcement Module
Collapse
No announcement yet.
(not) drop tables when running app? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • (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
    It's an FAQ

    Please see this thread and others.

    Comment


    • #3
      Thank you.

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

      Comment


      • #4
        I'll get this added to the reference guide (tracked as https://jira.springsource.org/browse/ROO-627).

        Comment


        • #5
          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>

          Comment


          • #6
            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.

            Comment


            • #7
              ROO-627 is now completed. Both the persistence.xml suggestion and reference guide section have been added.

              Comment

              Working...
              X