spring-data-jdbc

Generates and reviews Spring Data JDBC entities, aggregates, and repositories following project conventions.

Updated May 4, 2026
One-click install
npx skills add https://github.com/studenkov/FinanceTracker --skill spring-data-jdbc-studenkov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-data-jdbc
Source: https://github.com/studenkov/FinanceTracker/tree/main/.agents/skills/spring-data-jdbc
Command: npx skills add https://github.com/studenkov/FinanceTracker --skill spring-data-jdbc-studenkov

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Spring Data JDBC has strict aggregate-boundary rules that differ fundamentally from JPA, and mixing the two stacks produces broken mappings, illegal relationship shapes, and repositories for owned children. This Skill enforces correct Spring Data JDBC patterns by detecting project conventions first, then applying implementation rules for entities, aggregates, and repositories. ## Core Features & Use Cases - Entity authoring and review: Creates or modifies @Table entities with correct @Id, @Column, @Embedded, and @MappedCollection usage, with explicit guards against JPA leakage (jakarta.persistence imports, HibernateProxy patterns, @GeneratedValue). - Aggregate boundary management: Models cross-aggregate links with AggregateReference, enforces link entities for one-to-many and many-to-many relationships between aggregates, and guides migrations between owned children and separate aggregate roots. - Repository generation: Creates repositories only for aggregate roots, with derived queries, named-parameter @Query methods, @Modifying statements, and service-layer transaction boundaries. - Use Case: When asked to add a one-to-many relationship between Order and Product (both aggregate roots), the Skill reads the aggregate rules first and generates a link entity (OrderProductRef) held via @MappedCollection with AggregateReference<Product, Long>, instead of an illegal direct @MappedCollection to the other root. ## Quick Start Add a Spring Data JDBC entity for customers with a repository, following the project's existing conventions.

Frequently Asked Questions about spring-data-jdbc

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I model a one-to-many relationship between two Spring Data JDBC aggregates?

Create a link entity owned by the holding side via @MappedCollection, where each link entry carries an AggregateReference<Target, IdType> to the other root. Never use @MappedCollection pointing directly at another aggregate root, as that would make it an owned child and destroy its independent lifecycle.

How do I create a Spring Data JDBC repository for an entity?

First confirm the entity is an aggregate root (aggregateRootFqn == null) and that no repository already exists. Then declare a public interface named <Entity>Repository extending ListCrudRepository<T, ID>, with the ID generic matching the entity's @Id type exactly.

What is the difference between Spring Data JDBC and Spring Data JPA entity mappings?

Spring Data JDBC uses @Table and @Column from org.springframework.data.relational.core.mapping and has no lazy loading, proxies, @ManyToOne, @JoinColumn, or @GeneratedValue. Cross-aggregate links use AggregateReference instead of object references, and owned children are saved only through the root's repository.

Can I reference an owned child of another aggregate with a foreign key field?

No. Referencing a non-root member of another aggregate is illegal in any shape, including raw FK columns, because such links are invisible to referencedBy tooling and dangle when the owner is deleted. Instead re-frame the direction, promote the child to its own aggregate root, or reference the owning root.

Does this Skill work without the Spring MCP server connected?

Yes. When Spring MCP tools like get_jdbc_entity_details are unavailable, the Skill falls back to direct file reads and grep over both Kotlin and Java sources to derive id types, aggregate roots, owned children, and inbound references. It announces fallback mode explicitly at the start of the task.

Why must UPDATE and DELETE @Query methods have @Modifying in Spring Data JDBC?

Spring Data JDBC requires @Modifying from org.springframework.data.jdbc.repository.query on every UPDATE or DELETE @Query so the framework executes the statement as a modification rather than a select. The conventional return type is int, carrying the affected row count.