com.marringtons.object
Interface Migration.Interface

Enclosing interface:
Migration

public static interface Migration.Interface

Interface is used by inner classes of migration classes to define a migrate method used to move to a more recent version of a DAO that has been updated.


   public class Migration
     {
       public static class MyObject
         {
           public static class V20050412 implements Migration.Interface
             {
               ... copy of external MyObject class before it is changed
               public DAO migrate()  // method used to migrate between versions
                 { return V20050412toMyObject.copy( this); }
               private static DTO V20050412toMyObject(
                 new V20050412(), new MyObject());
             }
         }
     }

 
Note that you will have to follow the DAO object class path. If the DAO object is an inner class, create a class the same name and specify it as an inner class of that within Migrations.

Author:
Paul Marrington

Method Summary
 DAO migrate()
          When a database object class needs to change, copy it as an inner class into the Migrations class in the same package and have it implement Migration.Interface.
 

Method Detail

migrate

public DAO migrate()
When a database object class needs to change, copy it as an inner class into the Migrations class in the same package and have it implement Migration.Interface. Lastly implement this migration() method to copy from the older (this) to the newer item. Use DTO to automate most of this. The mapped version allows fields to be renamed.
 public DAO migrate()
 	{
 		OriginalDAOname replacement = new OriginalDAOname();
 		if (dto == null) dto = new DTO(replacement, this);
 		dto.copy(replacement, this);
 		replacement.fieldToAdd = fieldToRemove * 22;
 		return replacement;
 	}

 private static DTO	dto;
 

Returns:
replacement object - properly loaded.


Copyright © 2005 Paul Marrington http://library.marringtons.com