How to update database schema created using ORM tool?

I am looking for a general solution for updating a database schema using ORM tools like JPOX or Hibernate. How do you do this in your projects?

The first solution that comes to my mind is to create your own mechanism for updating databases, while SQL scripts do all the work. But in this case, I will have to remember to create new scripts every time I update object mappings. And I still have to deal with low-level SQL queries, and not just define the mappings and let the ORM tools do all the work ...

So the question is how to do it right. Perhaps some tools can simplify this task (for example, I heard that Rails has such a mechanism), if so, please help me decide which ORM tool to choose for my next Java project.

+5
source share
8 answers

LiquiBase is an interesting open source library for processing database refactoring (updates). I have not used it, but will definitely let it try my next project, where I need to update the db schema.

+7
source

, ORM - . , ORM script, diff

, google SQLCompare - , .

+2

SQL- SQL, , , . - , .

+2
+1

.

SOW :

+1

, . , script 10 11, 11 12 .. , . , .

, , ! Hibernate!

0

When working with Hibernate, I use the installer class, which is launched from the command line and has options for creating a database schema, inserting basic data and dynamically updating the database schema using SchemaUpdate . I find this very useful. It also gives me the opportunity to put one-time scripts that will run when a new version is launched, for example, fill in a new field in an existing database table.

0
source

All Articles