users@glassfish.java.net

Re: Table schema updates in JPA

From: <glassfish_at_javadesktop.org>
Date: Mon, 07 Jul 2008 10:53:40 PDT

DB Maintenance on that level is really a bit out of scope for the JPA. It's simply too high level, and very DB specific. Plus it doesn't account for any other possible side affects that may need to occur when converting from one schema to another. For example, perhaps a single table in the old version was normalized in to multiple tables. While JPA could perhaps create the new table, there's no real hook that will let you run code to handle the moving of the data from the original table in to the new tables.

Plus there's potential conflicts with constraints and foreign keys.

Simply put, it's a better practice to have a script or piece of code responsible for migrating a database schema to a new version.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=284811