Fwd: [xplanner-scm] [1191] trunk/xplanner/war/WEB-INF: To get rid of hibernate in JdbcMigrationTaskSupport classes

"Jacques Morel" <[email protected]> Thu, 6 Jul 2006 17:34:59 -0500
Newsgroups gmane.comp.java.xplanner.devel
Message-ID <[email protected]>
Team,

A few comments to this isolated review (I haven't reviewed everything yet).
So nothing to pick on Mateusz especially since he is the only one lately
that did anything to xplanner (pun intended... ;-) :
Let's not replicate hardcopied queries. This makes multi-database support
and database refactoring very hard. From now on, let's externalize
everything including migration task queries. Obviously during migration
tasks the schema may be different than the latest schema (hence not been
able to use hibernate for migrating) so we need to segregate somehow
migration queries from production queries. At this point I don't have any
preference so takers be choosers (update
http://docs.codehaus.org/pages/editpage.action?pageId=30167 to reflect the
choice and post the choice on the development mailing list): we could keep
the migration queries with the production queries that are closely related.
This may need to split off the hibernate spring beans to be loaded first by
autopatch since as of this change spring is loaded after autopatch is run.
Why is that btw Mateusz? Another way is to have a properties file that keep
all migration queries. Ultimately when we introduce a dynamic language (like
groovy, jruby) we could use simple inclusion of database specific query
constants to inject the correct queries.

Jacques

---------- Forwarded message ----------
From: mprokopowicz-yCVjj/[email protected] <mprokopowicz-yCVjj/[email protected]>
Date: 5 Jul 2006 09:38:32 -0000
Subject: [xplanner-scm] [1191] trunk/xplanner/war/WEB-INF: To get rid of
hibernate in JdbcMigrationTaskSupport classes
To: scm-XLRE/[email protected]

  Revision 1191 <http://fisheye.codehaus.org/changelog/xplanner/?cs=1191>
Author mprokopowicz Date 2006-07-05 04:38:31 -0500 (Wed, 05 Jul 2006) Log
Message

To get rid of hibernate in JdbcMigrationTaskSupport classes
To run autopatch before spring context has been initialized

Modified Paths

   -
   trunk/xplanner/src/com/technoetic/xplanner/upgrade/AdminSpamMigrationTaskSupport.java<#10c3e0da279e90f4_trunkxplannersrccomtechnoeticxplannerupgradeAdminSpamMigrationTaskSupportjava>
   -
   trunk/xplanner/src/com/technoetic/xplanner/upgrade/CleanUpDuplicateUsers.java<#10c3e0da279e90f4_trunkxplannersrccomtechnoeticxplannerupgradeCleanUpDuplicateUsersjava>
   -
   trunk/xplanner/src/com/technoetic/xplanner/upgrade/RemoveIterationDeletionRightsFromEditor.java<#10c3e0da279e90f4_trunkxplannersrccomtechnoeticxplannerupgradeRemoveIterationDeletionRightsFromEditorjava>
   - trunk/xplanner/war/WEB-INF/web.xml<#10c3e0da279e90f4_trunkxplannerwarWEBINFwebxml>

 Diff Modified:
trunk/xplanner/src/com/technoetic/xplanner/upgrade/AdminSpamMigrationTaskSupport.java
(1190 => 1191)

--- trunk/xplanner/src/com/technoetic/xplanner/upgrade/AdminSpamMigrationTaskSupport.java	2006-07-03
12:22:19 UTC (rev 1190)
+++ trunk/xplanner/src/com/technoetic/xplanner/upgrade/AdminSpamMigrationTaskSupport.java	2006-07-05
09:38:31 UTC (rev 1191)
@@ -17,7 +17,7 @@
                         "where p.id = pr.person_id and r.id =
pr.role_id and\n" +
                         "r.role in ('admin', 'sysadmin') and p.is_hidden=0;");
         int id = template.queryForInt("select nextId from identifier");
-        template.update("update identifier set nextId = " + ++id);
+        template.update("update identifier set nextId = nextId + 1");
         int sysadminRoleId = template.queryForInt("SELECT id FROM
role where role = 'sysadmin'");
         template.update(
             "insert into permission (id, principal, name,
resource_type, resource_id, positive) values (?,?,?,?,?,?)",

 Modified:
trunk/xplanner/src/com/technoetic/xplanner/upgrade/CleanUpDuplicateUsers.java
(1190 => 1191)

--- trunk/xplanner/src/com/technoetic/xplanner/upgrade/CleanUpDuplicateUsers.java	2006-07-03
12:22:19 UTC (rev 1190)
+++ trunk/xplanner/src/com/technoetic/xplanner/upgrade/CleanUpDuplicateUsers.java	2006-07-05
09:38:31 UTC (rev 1191)
@@ -8,7 +8,6 @@
 import java.util.Vector;

 import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
 import org.springframework.dao.DataAccessException;

 import com.technoetic.xplanner.security.SecurityHelper;
@@ -125,8 +124,7 @@
                       ")");
     }

-    private void changeCustomerInUserStory(Map userToBeCleaned, Map
userToBeDeleted)
-        throws HibernateException {
+    private void changeCustomerInUserStory(Map userToBeCleaned, Map
userToBeDeleted){
         List list =
             template.queryForList("select id, name from story where
customer_id=" + userToBeDeleted.get("id"));
         Iterator iterator = list.iterator();
@@ -141,8 +139,7 @@
         }
     }

-    private void changeRoleAssociation(Map userToBeCleaned, Map
userToBeDeleted)
-        throws HibernateException {
+    private void changeRoleAssociation(Map userToBeCleaned, Map
userToBeDeleted){

         List listAssociation =
             template.queryForList("select person_id, project_id,
role_id from person_role where" +

 Modified:
trunk/xplanner/src/com/technoetic/xplanner/upgrade/RemoveIterationDeletionRightsFromEditor.java
(1190 => 1191)

--- trunk/xplanner/src/com/technoetic/xplanner/upgrade/RemoveIterationDeletionRightsFromEditor.java	2006-07-03
12:22:19 UTC (rev 1190)
+++ trunk/xplanner/src/com/technoetic/xplanner/upgrade/RemoveIterationDeletionRightsFromEditor.java	2006-07-05
09:38:31 UTC (rev 1191)
@@ -12,8 +12,6 @@
 import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.StatementCallback;

-import com.technoetic.xplanner.db.hibernate.IdGenerator;
-
 public class RemoveIterationDeletionRightsFromEditor extends
JdbcMigrationTaskSupport {

     public RemoveIterationDeletionRightsFromEditor() {
@@ -21,8 +19,8 @@
     }

     protected void migrate() throws Exception {
-        final int nextId = IdGenerator.getNextPersistentId();
-        IdGenerator.setNextPersistentId(nextId + 1);
+        final int nextId = template.queryForInt("select nextId from
identifier");
+        template.update("update identifier set nextId = nextId + 1");
         final int roleId = template.queryForInt("SELECT id from role
where role = 'editor'");
         template.execute(new StatementCallback() {
             public Object doInStatement(Statement stmt) throws
SQLException, DataAccessException {

 Modified: trunk/xplanner/war/WEB-INF/web.xml (1190 => 1191)

--- trunk/xplanner/war/WEB-INF/web.xml	2006-07-03 12:22:19 UTC (rev 1190)
+++ trunk/xplanner/war/WEB-INF/web.xml	2006-07-05 09:38:31 UTC (rev 1191)
@@ -183,11 +183,11 @@
   </listener>

   <listener>
-    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    <listener-class>com.technoetic.xplanner.filters.XPlannerMigrationLauncher</listener-class>
   </listener>

   <listener>
-    <listener-class>com.technoetic.xplanner.filters.XPlannerMigrationLauncher</listener-class>
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>

   <servlet>

  --------------------------------------------------------------------- To
unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Xplanner-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xplanner-devel