Skip to content

feat(mybatis): index <resultMap> and link statements that use it (#592)#595

Open
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/592-mybatis-resultmap
Open

feat(mybatis): index <resultMap> and link statements that use it (#592)#595
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/592-mybatis-resultmap

Conversation

@maxmilian
Copy link
Copy Markdown

@maxmilian maxmilian commented May 31, 2026

Summary

Fixes #592. The MyBatis XML extractor indexes <select|insert|update|delete|sql> but not <resultMap>, so "which statements use this result map" queries return nothing.

(Note: <sql> fragments raised in the original report are already indexed on current main — this PR adds the remaining <resultMap> piece.)

Fix

src/extraction/mybatis-extractor.ts

  • Add resultMap to the element scan, so each <resultMap id="..."> becomes a node — the same method-shaped model already used for statements and <sql> fragments, qualified <namespace>::<id>, with a contains edge from the file. No new node kind.
  • Emit a reference from any statement carrying resultMap="..." to that result-map node, mirroring the existing <include refid="..."><sql> link.

src/resolution/callback-synthesizer.ts

  • Guard the Java↔XML bridge. It suffix-matches xml method nodes by <Class>::<id>; without a filter, a Java method whose name collides with a <sql>/<resultMap> id would wrongly bridge to it. Skip those non-statement nodes (identified by signature) — only real statements correspond to Java mapper methods. (This also closes the same latent over-bridge for <sql> fragments.)

This lets callers / impact / trace answer "which statements use this result map".

Tests (__tests__/frameworks-integration.test.ts)

  • A <resultMap id="userResult"> is indexed (qualified …UserMapper::userResult, signature <resultMap> type=User).
  • A <select resultMap="userResult"> produces an edge to that result map.
  • A Java method deliberately named userResult does not bridge to the result map (guard verified).

Full suite green locally (npm test).

Scope

Result-map-level linkage only. Field-level mapping (<result column=… property=…> / <id> entries as individual nodes — the "specific field → methods" association in the issue) is not modeled here; that needs a column/property node kind and is a larger design decision. Happy to follow up if you want that granularity. <resultMap extends="…"> inheritance is likewise left for a follow-up.

@maxmilian maxmilian force-pushed the fix/592-mybatis-resultmap branch from fe8f76b to b488957 Compare May 31, 2026 15:09
…bymchenry#592)

The MyBatis XML extractor indexed <select|insert|update|delete|sql> but
not <resultMap>, so "which statements use this result map" queries found
nothing. Index each <resultMap id="..."> as a node (same method-shaped
model as the existing statements/sql fragments, qualified <namespace>::<id>)
and emit a reference from any statement carrying resultMap="..." to it —
mirroring the existing <include refid> → <sql> link.

Also guard the Java↔XML bridge: it suffix-matches xml method nodes by
<Class>::<id>, so without a filter a Java method whose name collides with
a <sql>/<resultMap> id would wrongly bridge to it. Skip those non-statement
nodes (identified by signature) — only real statements map to Java methods.

Tests: a <resultMap> is indexed and a <select resultMap="..."> links to it,
and a same-named Java method does NOT bridge to the result map.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maxmilian maxmilian force-pushed the fix/592-mybatis-resultmap branch from b488957 to a9a5b47 Compare May 31, 2026 15:12
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.

Should we also include the resultMap and SQL from the MyBatis XML in the index

1 participant