views:

14

answers:

1

Hello there,

I was learning some JPA to teach to some java friends and I was wondering, how do you handle updates that comes after the creation of the db in JPA? Let's say I have a production environment where there's data that I cannot lose.

Some changes comes in and how do I apply that on my production environment? It there a way that JPA would only update the changes on the database?

Or do I need to manually create a SQL script to update my database?

Is there any other options?

[]'s Rodrigo Dellacqua

A: 

Some changes comes in and how do I apply that on my production environment? It there a way that JPA would only update the changes on the database?

Nothing standardized. In other words, that would be a provider specific feature. For example, Hibernate has a SchemaUpdate tool that can (in theory) safely update a database schema. In practice, many don't use that on a production database (including me).

Or do I need to manually create a SQL script to update my database?

Using migration scripts (and maybe a database migration tool) is IMO the safe way to handle this and is the way to go on real life projects.

And again, some migration tools might provide support for a given JPA provider. For example, liquibase does offer Hibernate support and can diff your Entities against a database to generate a change script.

Pascal Thivent