I'd like a tool which allows me to perform custom logic based on an existing schema. I'd like to piggy back off of the work hibernate has done with it's reverse engineering but I'd like to do my own custom things instead of generating hibernate entity files. Is there a way to piggy back off of hibernate's logic which lists all tables, columns, primary keys and foreign keys etc?
I'm thinking of an interface like
public interface DatabaseVisitor { void onTable(String TABLE_CAT, String TABLE_SCHEM, String TABLE_NAME, String TABLE_TYPE, ...); void onColumn(String TABLE_CAT, String TABLE_SCHEM, String TABLE_NAME, String COLUMN_NAME , int DATA_TYPE, ...); void onPrimaryKey(String TABLE_CAT, String TABLE_SCHEM, String TABLE_NAME, String COLUMN_NAME , ...); void onImportedKey(...); void onExportedKey(...); void onSequence(...); ... }
And a service like:
public interface DatabaseExplorer { void explore(DataSource ds, Dialect dialect, DatabaseVisitor visitor, DatabaseVisitorFilter filter); }
I've looked through the hibernate sources but I can't find a way to re-purpose the hibernate reverse engineering. Is there any chance that it could be refactored into a general purpose schema visitor?
Thanks, Lance.
|