Package org.dellroad.stuff.schema

Classes supporting automated database schema management.

See:
          Description

Interface Summary
DatabaseAction<T> Database action interface.
SchemaUpdate<T> A one-time database schema update.
 

Class Summary
AbstractSchemaUpdate<T> Support superclass for SchemaUpdate implementations with standard bean property implementations.
AbstractSchemaUpdater<D,T> Handles the initialization and schema maintenance of a database.
AbstractSpringSchemaUpdate<T> Support superclass for SchemaUpdates declared in Spring BeanFactorys that infer their names and required predecessors from their Spring bean attributes.
AbstractUpdatingDataSource A DataSource that wraps an inner DataSource and automatically performs some update operation on the inner DataSource on first access.
SchemaUpdateEdgeLister<T> TopologicalSorter.EdgeLister implementation reflecting SchemaUpdate predecessor constraints.
SchemaUpdatingDataSource A DataSource that wraps an inner DataSource and automatically intializes and updates the database schema using a SQLSchemaUpdater on first access.
SpringSQLSchemaUpdate Spring-enabled SQL SchemaUpdate.
SpringSQLSchemaUpdater SQLSchemaUpdater optimized for use with Spring.
SQLCommand An SQL DatabaseAction that executes a single SQL statement.
SQLCommandList Holds and executes a configured SQL script, possibly containing multiple statements.
SQLSchemaUpdater Concrete extension of AbstractSchemaUpdater for SQL databases.
UpdatingDataSource A DataSource that wraps an inner DataSource and automatically applies a configured SQLCommandList on first access.
 

Package org.dellroad.stuff.schema Description

Classes supporting automated database schema management.

Features include:

See SpringSQLSchemaUpdater for an example of how to declare your DataSource and associated schema updates in a Spring application context.

Updates may have ordering constraints, and these should be declared explicitly. Once you have done so, then you may safely "cherry pick" individual schema updates for merging into different code branches without worrying whether the schema will get messed up, because any ordering constraint violations will be detected automatically. This verification step is required to detect inconsistencies between the updates and the current code.

See DellRoad Stuff's ant macros for the schemacheck ant macro that can be used to verify that your delcared schema updates, when applied to the original schema, yield the expected result (which is typically generated automatically by your schema generation tool from your current code). It is also a good idea to compare your generated shema matches to an expected result during each build to detect schema changes caused by e.g., inadvertent changes to model classes.

The central classes are SQLSchemaUpdater and SpringSQLSchemaUpdater.