Repository navigation
Embedded DB2 -> Spring JDBC repositories that run the programs' own SQL (#3618) - #3680
Merged
Merged
Conversation
…QL (#3618) Engine: every embedded SQL statement now keeps its text (comments stripped, whitespace collapsed, literals kept) in a new sql_statement_data.statement_text column, healed into existing DBs. The rehydrator and galaxy_ir read it, and an older DB loads None. IR: GalaxyIR.db2_tables() treats each table (the unqualified name; every spelling kept) as one unit, joining: - its EXEC SQL DECLARE ... TABLE (declared_in, line, columns); - every embedded statement against it (file, line, verb, access, cursor, host variables, text); - for a DECLARE CURSOR, the cursor's OPEN / FETCH / CLOSE lines. The skeleton's estate.json carries it. Forge (cobol_to_java_db2_forge.py, registered in SkeletonForges). Each table a converted program uses becomes: - <Table>Row (dto.db2): the DECLAREd columns with Java types for their SQL types (DECIMAL -> BigDecimal, DATE -> LocalDate, ...), each citing type, length, nullability and column number; - <Table>Repository (repository.db2): a @repository over NamedParameterJdbcTemplate with one method per statement, running the program's own SQL: - host variables become named parameters (:WS-ACCT-ID -> :wsAcctId, indicators dropped); - a singleton SELECT's INTO list is dropped (queryForMap); - a cursor's SELECT is run as queryForList, citing its OPEN / FETCH / CLOSE lines; INSERT / UPDATE / DELETE / MERGE -> update; - a positioned WHERE CURRENT OF keeps its text with a TODO. Each program's service gets its tables' repositories injected. Not JPA: DECLARE TABLE states no primary key, and an invented one would be a guess. With a database.engine other than db2, the repository says the SQL is DB2's. Results: - CardDemo: 2 tables, 14 statements; - CBSA: 3 tables, 31 statements, all with row classes; - GENAPP: 7 tables, 33 statements (no DECLAREs in the repo, so maps only), 1 positioned. - 6 corpora x 13 configs compile via --scan. - ir_join_diff: only `programs` changes, on the DB2 corpora (the statement text). - preflight all PASS; full suite 11,682 passed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
squid-protocol
force-pushed
the
feat/db2-repos-3618
branch
from
September 25, 2026 20:24
8cfb7d9 to
0e6b695
Compare
Contributor
squid-protocol
added a commit
that referenced
this pull request
Sep 25, 2026
Conflict in skeleton_forges: kept both TraceLog wiring and Db2Forge. Db2Forge now records each statement method (source file:line, "DB2 table access", a TODO when the engine isn't db2) and each DECLAREd row class. Also untangles the #3617/#3618 comments glued onto one ESTATE_JOINS line by the #3680 conflict resolution. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
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.
Closes #3618 (epic #3625).
The idea: carry the program's SQL, don't reinvent it
Until now the engine kept each embedded statement's verb, tables, cursor and host variables, but not the statement. A repository method could only guess what the query does. So:
sql_statement_data.statement_text: every statement's text (comments stripped, whitespace collapsed, literals kept). The column is healed into existing DBs; the rehydrator andgalaxy_irread it; a pre-#3618 DB loadsNoneGalaxyIR.db2_tables(): each table (unqualified name, all spellings kept) with itsDECLARE … TABLEcolumns and every statement against it; a cursor carries its OPEN / FETCH / CLOSE lines. Inestate.json<Table>Rowdata class (DECLAREd columns, SQL→Java types) and a<Table>RepositoryoverNamedParameterJdbcTemplate, one method per embedded statement, running the program's own SQLSQL handling:
:WS-ACCT-ID→:wsAcctId), with indicators dropped;SELECT … INTO :x, :yloses its INTO list and returns the row (queryForMap; SQLCODE +100 surfaces asEmptyResultDataAccessException);queryForList), and the javadoc lists its OPEN/FETCH/CLOSE lines;update;WHERE CURRENT OFkeeps its text, with a TODO.Real output (CardDemo COTRTLIC, a forward-browse cursor):
Not JPA, on purpose.
DECLARE TABLEstates no primary key, and an@Entityneeds one; inventing a key would be a guess. With adatabase.engineother thandb2, the repository states that the SQL is DB2's and needs review. Each program's service gets its tables' repositories injected.Results
Attributes consumed (consumer audit)
DB2 table access)DB2 table columns)Verified
ir_join_diff.py): onlyprogramschanges, on the three DB2 corpora (statements gained their text).db2_tablesis new.--scan.preflight.py: all PASS. Full suite: 11,682 passed.to_jdbc(INTO, indicators, cursor, positioned), SQL→Java types, the join with its cursor use, a pre-Java conversion: embedded DB2 (table access + DCLGEN) -> repositories, dialect per config #3618 DB, and end to end (row class, repository methods and SQL, injection, audit).🤖 Generated with Claude Code
https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g