Repository navigation
jdbc.standalone, maven/ddl, maven/jdbc: a database into CWM and a model back into it, as library and Maven goals - #92
Merged
stbischof merged 3 commits intoNov 14, 2026
Conversation
…t OSGi A new module wires by hand what OSGi wires as services. CwmJdbcImport reads a database into a catalog by selection rules, through a connection, a DataSource or a URL with a driver from a class loader. CwmJdbcExport cuts a copy of a model to a selection, writes its DDL in the dialect of the database and runs it, in one transaction where the database runs DDL in one; with dropFirst the drop script of the same model runs first, each statement only where the database holds the element it works on, so an export runs again and again. A rejected statement ends the export with its position, element and what remains. readBack() reads back what an export wrote, for a comparison with the written model. The module is registered in resource/relational. Left out: the Maven goals and the example, which come with their own modules. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
A new plugin writes the create and drop scripts of a CWM model, one per SQL dialect, chosen by selection rules, through ddl.render. Its settings are those of the DDL generator, strict among them, and the script files carry the dialect, the model and the rules in their head. The module is registered in maven. Left out: the goals cwm-jdbc:import and cwm-jdbc:export, which come with their own module. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
A new plugin reads a live database into a CWM catalog XMI by selection rules, cwm-jdbc:import, and writes a catalog into a database, cwm-jdbc:export, both through jdbc.standalone. The driver comes from the goal's dependencies or as Maven coordinates, the credentials from the settings; the export writes the DDL of the database's dialect, with dropFirst again and again, and fails the build on a statement the database rejects or, strict, on what the dialect cannot write. The module is registered in maven, and maven/README.md now shows the relational goals, how they fit together and the selection rules they share. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR follows #91 with the modules that use the selection rules from outside OSGi: a database read into CWM and a model written back into it, and two Maven plugins for that. Each module comes in its own commit.
Commits
resource/relational/jdbc.standalone: wires by hand what OSGi wires as services.CwmJdbcImportreads a database into arelational::Catalogby selection rules. It takes aConnection, aDataSourceor a URL with a driver from a class loader.CwmJdbcExportcuts a copy of the model to a selection, writes its DDL in the dialect of the database and runs it. Where the database runs DDL in transactions, everything runs in one.ExportSettings.dropFirstruns the drop script of the same model first. Each drop statement runs only where the database holds the element it works on, so an export can be repeated as often as needed. This holds even whereIF EXISTSis missing (REVOKE,DROP ROLE,DROP CONSTRAINTandDROP INDEXin MySQL).StatementFailedException. It names the statement, its position, the element and what ran before it.Exported.readBack()reads back what an export wrote, for a comparison withCatalogDiffer.maven/ddl: the goalcwm-ddl:generate.ddl.render.strictamong them.maven/jdbc: the goalscwm-jdbc:importandcwm-jdbc:export, both onjdbc.standalone.cwm-jdbc:importreads a live database into a catalog XMI by selection rules.cwm-jdbc:exportwrites a catalog into a database in its dialect, withdropFirstif set. The build fails on a statement the database rejects, or, withstrict, on what the dialect cannot write.maven/README.mdnow shows the relational goals, how they fit together and the selection rules they share.The markdown of
maven/README.mdfollows the lint rules of the editor config check now, including the table it already had.An example that runs the whole round trip comes separately.
Needs
The SQL dialect API of eclipse-daanse/org.eclipse.daanse.sql#92 in its snapshot, as #91 does.