303-frameworks-spring-data-jdbc

303-frameworks-spring-data-jdbc is a cursor rule for Cursor from jabrena/cursor-rules-spring-boot. It costs 0 tokens per session (4,709 once invoked), scanned A, original, Apache-2.0.

A set of guidelines for using Spring Data JDBC, a database library that gives you direct SQL control while providing repository abstractions. It also covers Java records, which are concise immutable data classes.

In plain words
What is it for?
Use it when building Spring applications that read and write relational database data with repositories, Java records, custom SQL, and service-level transactions.
Why use it?
It helps keep database code simpler and makes data models predictable. It also clarifies how to handle updates, relationships, custom queries, and transactions.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/jabrena/cursor-rules-spring-boot/303-frameworks-spring-data-jdbc
Clone the repo
git clone --depth 1 https://github.com/jabrena/cursor-rules-spring-boot

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 303-frameworks-spring-data-jdbc

README.md
[![agentmods](https://agentmods.dev/badge/rules/jabrena/cursor-rules-spring-boot/303-frameworks-spring-data-jdbc.svg)](https://agentmods.dev/rules/jabrena/cursor-rules-spring-boot/303-frameworks-spring-data-jdbc)
Your own site
<a href="https://agentmods.dev/rules/jabrena/cursor-rules-spring-boot/303-frameworks-spring-data-jdbc"><img src="https://agentmods.dev/badge/rules/jabrena/cursor-rules-spring-boot/303-frameworks-spring-data-jdbc.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 4,709 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.04709
Opus 5 $0.00000 $0.02354
Sonnet 5 $0.00000 $0.00942
Haiku 4.5 $0.00000 $0.00471

Measured 4d ago against content hash 44bfb339ccf2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

303-frameworks-spring-data-jdbc scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/303-frameworks-spring-data-jdbc.mdc · 729 lines

How it starts

The opening of the file, as written. The whole thing — 729 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Spring Data JDBC with Records

Spring Data JDBC provides a simpler alternative to JPA, offering direct SQL control while maintaining Spring's repository abstractions. When combined with Java records, it creates clean, immutable data models perfect for modern Java applications.

Implementing These Principles

These guidelines are built upon the following core principles:

  • Immutability: Use records for immutable entities that are thread-safe and predictable
  • Simplicity: Leverage Spring Data JDBC's straightforward approach over complex ORM mapping
  • Constructor Injection: Always use constructor-based dependency injection for better testability
  • Transaction Boundaries: Keep transactions at the service layer, not repository layer
  • SQL Control: Use custom queries when needed for optimal performance

Table of contents

  • Rule 1: Use Records for Entity Classes
  • Rule 2: Implement Repository Pattern Correctly
  • Rule 3: Handle Updates with Immutable Records
  • Rule 4: Design Aggregate Relationships Properly
  • Rule 5: Use Custom Queries for Complex Operations
  • Rule 6: Implement Proper Transaction Management
  • Rule 7: Embrace Single Query Loading to Eliminate N+1 Problems

Rule 1: Use Records for Entity Classes

Title: Prefer Records Over Classes for Entity Definitions Description: Records provide immutability, automatic equals/hashCode, and clean constructor-based mapping that works perfectly with Spring Data JDBC. They eliminate boilerplate code and ensure thread safety. Use @PersistenceCreator when you have multiple constructors to specify which one Spring Data JDBC should use. Use @Column to explicitly map record fields to database columns, especially when field names differ from column names.

Good example:

public record Customer(
    @Id 
    @Column("customer_id") 
    Long id,
    
    @Column("first_name") 
    String firstName,
    
    @Column("last_name") 
    String lastName,
    
    @Column("email_address") 
    String email,
    
    @Column("created_at") 
    LocalDateTime createdAt
) {
    // Constructor for Spring Data JDBC (explicit annotation when multiple constructors exist)
    @PersistenceCreator
    public Customer(Long id, String firstName, String lastName, String email, LocalDateTime createdAt) {
        this.id = id;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.createdAt = createdAt;
    }
    
    // Factory method for new entities
    public static Customer of(String firstName, String lastName, String email) {
        return new Customer(null, firstName, lastName, email, LocalDateTime.now());
    }
}

Read the full file on GitHub · 729 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 729 lines · 0 tokens per session scan A 44bfb339ccf2

Subscribe to this mod's changes

303-frameworks-spring-data-jdbc is a cursor rule published in the GitHub repository jabrena/cursor-rules-spring-boot (47 stars, last pushed 5mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 4,709 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.