|
From: <ian...@us...> - 2008-02-15 00:13:19
|
Revision: 751
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=751&view=rev
Author: iansmith
Date: 2008-02-14 16:13:12 -0800 (Thu, 14 Feb 2008)
Log Message:
-----------
Fixed bug which was causing noisy errors about version numbers during migration. Also now that it is corrected, we complain and abort if version numbers are wrong.
Modified Paths:
--------------
maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
Modified: maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java
===================================================================
--- maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-02-14 03:59:36 UTC (rev 750)
+++ maven/trunk/ogoglio-appdev/src/main/java/com/ogoglio/appdev/migrate/MigrationSupport.java 2008-02-15 00:13:12 UTC (rev 751)
@@ -136,23 +136,23 @@
for (int i = db_is; i < db_wants_to_be; ++i) {
String hbm_auto_flag = "update";
+ int expectedRecords = 1;
if (i == 0 && !isUpdate) {
hbm_auto_flag = "create";
+ expectedRecords = 0;
}
Migration current = getMigrationList()[i];
- Log.info("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:" + hbm_auto_flag);
+ Log.debug("DB: Attempting migration from " + i + " to " + (i + 1) + " with auto HBM:" + hbm_auto_flag);
//try to get hibernate to do the work
Configuration config = createConfigurationForHibernate(i + 1, hbm_auto_flag, useJNDI, propStore);
SessionFactory factory = config.buildSessionFactory();
- //subtle: if the ddlMode is create, hibernate blows away all the data (including our version number record)
- int expectedRecords = 1;
- if (!isUpdate) {
- expectedRecords = 0;
+ if (!setVersionNumberOfDbViaQuery(factory, i + 1, expectedRecords)) {
+ Log.error("Unable to set version number to "+(i+1)+"!");
+ return false;
}
- setVersionNumberOfDbViaQuery(factory, i + 1, expectedRecords);
try {
if (!current.patch(factory, servletConfig, ctx, i, i + 1)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|