Added a method to make it easier to insert schema migration calls.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1726 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert@gmail.com
2005-11-04 23:02:56 +00:00
parent e6fe41e4a7
commit 03344a7938
@@ -66,6 +66,22 @@ public class SimpleRepository extends Repository
{
super(provider);
_dbident = dbident;
// give the repository a chance to do any schema migration before
// things get further underway
try {
execute(new Operation() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
migrateSchema();
return null;
}
});
} catch (PersistenceException pe) {
Log.warning("Failure migrating schema [dbident=" + _dbident + "].");
Log.logStackTrace(pe);
}
}
/**
@@ -299,6 +315,19 @@ public class SimpleRepository extends Repository
});
}
/**
* Derived classes can override this method and perform any schema
* migration they might need (using the idempotent {@link JDBCUtil} schema
* migration methods). This is called during the repository's constructor
* and will thus take place before derived classes (like the {@link
* JORARepository} introspect on the schema to match it up to associated
* Java classes).
*/
protected void migrateSchema ()
throws SQLException, PersistenceException
{
}
/**
* Called when we fetch a connection from the provider. This gives
* derived classes an opportunity to configure whatever internals they