/apache-cayenne-6:cayenne-runtimefrom apache-cayenne-6
Bootstraps CayenneRuntime in Java applications — constructing runtime, wiring DataSource, configuring connection pools, creating ObjectContexts, and integrating with Bootique, Spring, or plain Java.
Ships in apache-cayenne-6. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Bootstrap CayenneRuntime and use ObjectContext for CRUD in a Java application.
${CLAUDE_PLUGIN_ROOT}/references/runtime-api.md — CayenneRuntimeBuilder methods, ObjectContext API, transaction patterns, lifecycle rules.This plugin is for Cayenne 6.0. Look at the project's build file first: if it depends on Cayenne 5.x, the API below
doesn't apply. Tell the user to install apache-cayenne-5@apache-cayenne instead, and stop.
Where does the user's app construct CayenneRuntime? Common patterns:
main() method or a singleton holder.@Provides method in a module (provideCayenneRuntime(@Inject DataSource ds)). If editing a Bootique app, mention that the java-dev:bootique-config skill (if available) can help with the surrounding config wiring.@Bean CayenneRuntime cayenneRuntime(DataSource ds) method in a configuration class.If none exists yet, create one. Apply runtime-api.md patterns:
CayenneRuntime runtime = CayenneRuntime.of()
.addConfig("cayenne-mydb.xml")
.defaultDataNode(dataSource) // any javax.sql.DataSource, or a DataNodeDescriptor
.build();
The project XML lists DataMaps only; the connection is always wired in code, as the DataSource of a DataNode:
| When | Use |
|---|---|
| Production app with Spring/Bootique/Hikari already managing the pool | .defaultDataNode(ds) — Cayenne reuses the external pool. |
| Standalone tool or test fixture with no external DI | CayenneDataSource.of(url).userName(..).password(..).pool(min, max).build() — Cayenne's built-in pool, passed to .defaultDataNode(..). |
| A node that needs a stable name, a pinned adapter or schema creation on startup | DataNodeDescriptor.of("name").dataSource(ds).createSchemaIfNeeded().build(), passed to .defaultDataNode(..) or .addDataNode(.., "map1", "map2"). |
Prefer the external DataSource when the app has one. Never put JDBC credentials in source control — keep them in the application's normal config mechanism.
ObjectContextObjectContext ctx = runtime.newContext(); // one per request/thread
Artist a = ctx.newObject(Artist.class);
a.setArtistName("Picasso");
ctx.commitChanges();
Rules:
CayenneRuntime is a heavy singleton — create once, share for app lifetime, call shutdown() on exit.ObjectContext is not thread-safe — new one per request/thread.ctx.localObject(other) to bring an object into the current context.commitChanges() is auto-transactional. For multi-step transactions:
runtime.performInTransaction(() -> {
// multiple commits in one transaction
return null;
});
Any throw rolls back the whole block.
Tell the user how to smoke-test:
ObjectContext ctx = runtime.newContext(); long count = ObjectSelect.query(SomeEntity.class).selectCount(ctx); — should return a number without throwing.If they hit CayenneRuntimeException: No DataNode..., the descriptor's <map> reference doesn't have a node — confirm the DataSource wiring went through CayenneRuntimeBuilder.defaultDataNode(...), or that addDataNode(..) lists that map.
CayenneRuntime per request. It's a heavyweight singleton. Cache it for the application lifetime.ObjectContext across threads. Not safe. Create one per thread.cayenne-*.xml for production. Use the application's secret management; pass a DataSource to the builder.commitChanges(). Mutations stay in memory until commit.shutdown() on app exit. Hangs the JVM on some pool implementations.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub apache/cayenne --plugin apache-cayenne-69 skills in this plugin
/cayenne-cgenUse this skill whenever the user wants to (re)generate Cayenne entity Java classes from a DataMap. Trigger on phrases like 'generate Java classes', 'regenerate entities', 'run cgen', 'create the entity classes', 'why is the Artist class missing fields', 'where did the `_Abstract*` classes come from', 'sync the entity classes with the model', or any request to materialize Java from the DataMap. Also trigger as a follow-up after modeling changes (someone added an entity, attribute, or relationship and now the Java side is stale). This skill exclusively uses the `cgen_run` MCP tool — it does NOT use `mvn cayenne:cgen` or the Gradle cgen task./cayenne-db-importUse this skill when the user wants to import database schema metadata into a Cayenne DataMap — the *model/mapping only*, not names or Java classes. Trigger on phrases like 'reverse engineer the database', 'import the schema', 'generate a DataMap from my DB', 'add the new tables from the DB into the model', 'import the customer table', 'create entities from these tables', or any request to read database metadata to populate or update a DataMap's XML. This is the only way the DB layer of the model (DbEntity, DbAttribute, DbRelationship) gets created or changed, whatever the size — a full schema, a batch of tables, or a single new table, column or FK. Hand-editing the DB layer in `cayenne-modeling` is allowed only when the user has explicitly said they do not use DB import; Object-layer edits (ObjEntity, ObjAttribute, ObjRelationship) always belong in `cayenne-modeling`. IMPORTANT — scope: this imports the mapping ONLY; it does not clean up the Object-layer names or (re)generate Java classes. When the user wants their whole project brought in line with the DB ('sync my project with the database', 'my schema changed, update everything', 'update my entities/classes from the DB'), that is the end-to-end `cayenne-full-db-sync` skill, which runs this import and then name cleanup and class generation. To regenerate classes alone use `cayenne-cgen`. The skill runs reverse engineering directly via the `dbimport_run` MCP tool when a DBConnector is already configured; otherwise it opens the CayenneModeler GUI via `open_project` to configure the connection first./cayenne-full-db-syncUse this skill when the user wants to bring their WHOLE Cayenne project in line with the database in one shot — the mapping, the Object-layer names, and the generated Java classes together. This is the end-to-end 'sync with the DB' workflow, and it orchestrates three skills in order: `cayenne-db-import` (import schema metadata into the DataMap) → `cayenne-model-naming` (polish the just-imported names) → `cayenne-cgen` (regenerate Java classes). Trigger on holistic phrases like 'sync my project with the database', 'sync with the DB', 'my schema changed, update everything', 'update my entities/classes from the database', 'reverse engineer and regenerate the classes', 'import the new tables and rebuild the entities', 'full DB sync', 'bring the model and classes up to date with the DB'. The distinguishing signal is scope: the user wants the whole project (mapping + names + Java code), not just one stage. For the *model/mapping only* (no name cleanup, no class generation) use `cayenne-db-import`; to (re)generate classes alone use `cayenne-cgen`; to clean names alone use `cayenne-model-naming`. Uses the `dbimport_run` and `cgen_run` MCP tools via the sub-skills; does NOT use Maven or Gradle goals./cayenne-modelerUse this skill when the user explicitly wants to open CayenneModeler (the GUI) on a Cayenne project, or when the modeling task is one the Modeler has to do — first-time DB connection setup for reverse engineering (delegated to cayenne-db-import), bulk relationship layout, multi-entity visual refactoring. Trigger on phrases like 'open the Modeler', 'open in CayenneModeler', 'launch the GUI', 'edit visually', 'show me the project in the Modeler'. Do NOT trigger for upgrading a project saved by an older Cayenne version — that's the cayenne-upgrade skill. Do NOT trigger as a fallback for ordinary a-la-carte XML edits — those belong in the cayenne-modeling skill, which is faster and doesn't require the user to context-switch./cayenne-modelingUse this skill whenever the user wants to edit, inspect, or extend the Cayenne ORM model in a project — adding or modifying entities, attributes, relationships, embeddables, named queries, stored procedures, or DataNodes. Trigger on phrases like 'add an ObjEntity', 'add a DbEntity', 'add a relationship', 'expose this column as an attribute', 'create a new DataMap', 'add a named query', 'create an embeddable', 'add a stored procedure', 'change the attribute type', 'mark this column as nullable', 'rename this entity', or any mention of a Cayenne `*.map.xml` or `cayenne-*.xml` file. Also trigger when the user references modeling concepts (ObjEntity, DbEntity, ObjAttribute, DbAttribute, ObjRelationship, DbRelationship, Embeddable, dbEntityName, deleteRule, dbAttributePath, dbRelationshipPath, defaultPackage) in the context of a Cayenne-using app. This is the *primary* skill for a-la-carte ORM model manipulation — direct XML edits, not the Modeler GUI. IMPORTANT — DB layer ownership: the DB layer (DbEntity, DbAttribute, DbRelationship) is owned by DB import and is NOT hand-edited by this skill, unless the user has explicitly said they do not use DB import for this project. Otherwise a DB-layer request, even for a single table or column, is routed to `cayenne-db-import`; this skill hand-edits the Object layer, queries, embeddables and config blocks./cayenne-model-namingUse this skill to clean up Object-layer names in a Cayenne DataMap — ObjEntity, ObjAttribute, and ObjRelationship names, plus DbRelationship names (the first-class unit of relationship cleanup — every FK has one whether or not an ObjRelationship was generated; the ObjRelationship name is synced to it when one exists) — so they read as descriptive, consistent Java. Trigger on phrases like 'clean up the model names', 'fix the entity names', 'these names look ugly', 'make the names descriptive', 'normalize the ObjEntity/attribute/relationship names', 'why is this relationship called team1', 'rename entities to be consistent', 'the import produced Gametype instead of GameType'. Invoke it on an explicit user request, or as a manual follow-up after a `cayenne-db-import` to polish the just-imported additions — it is never triggered automatically. IMPORTANT: this is a LIGHT polish pass — CayenneModeler's reverse-engineering already produces good names for the common case; only improve the specific things its deterministic algorithm cannot (run-together names with no separators like `gametype`, meaningless numbered names like `team1` from multiple relationships between two tables, and a common entity prefix that leaks into relationship names like `aaOrders`). Do NOT rewrite names that are already correct. This is Obj-layer naming polish; for structural model edits use `cayenne-modeling`, and for regenerating classes afterward use `cayenne-cgen`.Other plugins' skills for the same job