Skip to content

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 into
eclipse-daanse:mainfrom
stbischof:feature/jdbc-standalone-maven
Nov 14, 2026
Merged

stbischof merged 3 commits into
eclipse-daanse:mainfrom
stbischof:feature/jdbc-standalone-maven

Conversation

@stbischof

Copy link
Copy Markdown
Contributor

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

  1. resource/relational/jdbc.standalone: wires by hand what OSGi wires as services.
    • CwmJdbcImport reads a database into a relational::Catalog by selection rules. It takes a Connection, a DataSource or a URL with a driver from a class loader.
    • CwmJdbcExport cuts 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.dropFirst runs 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 where IF EXISTS is missing (REVOKE, DROP ROLE, DROP CONSTRAINT and DROP INDEX in MySQL).
    • A rejected statement ends the export with a 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 with CatalogDiffer.
    • Round trips on H2, DuckDB, PostgreSQL and MySQL.
  2. maven/ddl: the goal cwm-ddl:generate.
    • It writes the create and drop scripts of a CWM model per SQL dialect, chosen by selection rules, through ddl.render.
    • Its settings are those of the DDL generator, strict among them.
    • Each script file names the dialect, the model and the rules in its header.
  3. maven/jdbc: the goals cwm-jdbc:import and cwm-jdbc:export, both on jdbc.standalone.
    • cwm-jdbc:import reads a live database into a catalog XMI by selection rules.
    • cwm-jdbc:export writes a catalog into a database in its dialect, with dropFirst if set. The build fails on a statement the database rejects, or, with strict, on what the dialect cannot write.
    • The driver comes from the goal's dependencies or as Maven coordinates, the credentials from the settings.
    • maven/README.md now shows the relational goals, how they fit together and the selection rules they share.

The markdown of maven/README.md follows 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.

…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>
@stbischof
stbischof merged commit c5f3217 into eclipse-daanse:main Nov 14, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant