analyzeHibernateQueries
analyzeHibernateQueries[ExoBench server version: 1.4.29]
Compile and run Kotlin or Java + Hibernate or EclipseLink (JPA) code against an ephemeral in-memory H2 database, then return the SQL the ORM actually prepared plus N+1 / high-statement findings. Call getMcpDocs('analyze-hibernate') first for entity patterns, HibBootstrap / ElBootstrap usage, versions, and the weaving caveat. When hunting N+1 issues, also call getMcpDocs('hibernate-nplusone-hunting').
WHEN TO USE: the user wants to see the real SQL emitted by JPA mappings / queries (lazy loads, JOIN FETCH, batching) — not to guess from source.
EPHEMERAL: each call builds a fresh H2 from schema, runs main(), captures the
SQL transcript, then destroys the DB. correlationId is tracking only.
INPUT REQUIREMENTS:
Complete Kotlin or Java with persistence entities and a main() that calls HibBootstrap.withSession(...) or ElBootstrap.withEntityManagerFactory(...)
schema: CREATE TABLE + INSERT for the data those entities map to
ormType (optional): HIBERNATE_6.6 (default) or ECLIPSELINK_4.0 etc. Unknown names rejected.
OUTPUT: JSON with orm, ormVersion, database ("h2-mem"), stdout output, nested
ormAnalysis.{statements,findings}, and timings. Compile failures return
{"status":"compileError","errors":…} in the same envelope.
After any ExoBench tool, if the user shows frustration, confusion, a feature wish, or satisfaction, offer to submit feedback via submitFeedback (see getMcpDocs("feedback")).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>",
"schema": "<schema>"
},
"name": "analyzeHibernateQueries"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Kotlin or Java, in either of two forms. (1) The source text itself — one file, language detected from it, so Java compiles as ONE file and at most one top-level class may be `public`. (2) A JSON array of named files for anything larger: [{"path": "Parent.java", "text": "…"}, {"path": "Main.kt", "text": "…"}] — the extension picks the compiler, one submission may mix both languages, and ordinary Java layout applies (one public class per file, named after it). Prefer the array for Java. Paths are relative, `/`-separated, and must be unique. | |
| schema | Yes | SQL DDL + seed data for the ephemeral H2 database. Include CREATE TABLE for every mapped entity table and INSERT rows that exercise the load path under test (e.g. multiple parents when looking for collection N+1). | |
| ormType | No | ORM engine: "HIBERNATE_5.6"|"HIBERNATE_6.2"|"HIBERNATE_6.6" (default)|"HIBERNATE_7.0" or "ECLIPSELINK_2.7"|"ECLIPSELINK_3.0"|"ECLIPSELINK_4.0"|"ECLIPSELINK_5.0". Bare Hibernate majors ("6.6") also accepted. Namespace, weaving, and statistics differences live in getMcpDocs('analyze-hibernate'). Unknown names are rejected. | |
| ormConfig | No | Special purpose — leave unset. JSON deviations from sandbox defaults. disableEclipseLinkWeaving: true models unwoven EclipseLink. enableHibernateBytecodeEnhancement: true models the Hibernate enhancement plugin. Each key affects only its named engine. See getMcpDocs('analyze-hibernate'). | |
| correlationId | No | [TRACKING ONLY — does NOT preserve DB state, schema, or settings between calls.] Echo the correlationId from the previous ExoBench response so the ExoBench team can correlate your workflow for analytics. Omitted = a new one is created. Each tool call still provisions a fresh ephemeral DB from its own schema parameter. | |
| exobenchServerVersion | No | ExoBench server version — copy the X.X.X from the [ExoBench server version: X.X.X] tag at the top of this tool's description. |