Announcement Announcement Module
Collapse
No announcement yet.
upgrading and deploying Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • upgrading and deploying

    how does db upgrades and init deployment work with a roo app? will the app create my db the first the the war is deployed and ran or will roo generate a ddl file? then what happens when you want to upgrade and you have changes with your entities?

    i normally just keep a db script for each version that gets ran before deploying the war.

  • #2
    Roo uses JPA which allows you to map to existing tables or it will create the db schema at deployment time (check the Roo logs to see it happening). Changes to your domain model will require redeployment to the Web container and the database schema is adjusted at the same time. For this reason the ddl creation schema is set to 'create' in the persistence XML file which means that all entered data will be lost with each redeployment so JPA can create a complete new schema based on your latest changes to the domain model.

    So there is no need to keep or maintain a separate database ddl script as JPA takes care of this conveniently for you. When developing applications with Roo all of these details are managed automatically for you so you can concentrate on the development of your application.

    HTH,
    Stefan

    Comment


    • #3
      what if i don't want to lose my data?

      Comment


      • #4
        If you are using hibernate you can change the ddl settings in the persistence.xml from:

        <property name="hibernate.hbm2ddl.auto" value="create"/>

        to

        <property name="hibernate.hbm2ddl.auto" value="update"/>

        The other ORM providers have a similar syntax which you can google for.

        This way you will keep your data (as long as you use a persistent DB).

        However, as long as your domain model changes I suggest you keep using create so the changes can be accommodated cleanly. Only if your domain model is stable you could try to use 'update'.

        HTH,
        Stefan

        Comment

        Working...
        X