311-frameworks-spring-jdbc

Installation
SKILL.md

Spring JDBC — JdbcClient (Spring Framework 7+)

Apply Spring JDBC guidelines with JdbcClient as the default; use JdbcTemplate / NamedParameterJdbcTemplate only for legacy code or APIs not covered by JdbcClient (batch updates, KeyHolder, RowCallbackHandler streaming).

What is covered in this Skill?

  • Parameterized SQL (never concatenate user input)
  • JdbcClient fluent API (Spring Framework 7+) — preferred for queries and updates
  • Named parameters via JdbcClient; NamedParameterJdbcTemplate for legacy migration
  • RowMapper, query(Class), and records
  • Batch operations and generated keys (JdbcTemplate / JdbcOperations where needed)
  • Safe handling of generated keys (KeyHolder; single-row JdbcClient updates)
  • Service-layer @Transactional boundaries
  • Read-only transactions (@Transactional(readOnly = true))
  • Safe single-row access (optional() / findFirst() vs queryForObject)
  • Streaming large result sets (RowCallbackHandler, ResultSetExtractor)
  • DataAccessException handling (DuplicateKeyException, EmptyResultDataAccessException)
  • @JdbcTest slice testing with @Sql fixtures

Scope: Apply recommendations based on the reference rules and good/bad code examples.

Related skills

More from jabrena/cursor-rules-java

Installs
70
GitHub Stars
380
First Seen
Mar 25, 2026