← ClaudeAtlas

data-accesslisted

Data access patterns with Spring Data JPA, Hibernate 7.1, Flyway migrations, HikariCP tuning, N+1 prevention, caching, and query optimization. Use when user mentions database, JPA, queries, migrations, N+1, or slow queries.
IuliaIvanaPatras/claude-code-templates · ★ 0 · AI & Automation · score 65
Install: claude install-skill IuliaIvanaPatras/claude-code-templates
# Data Access Skill Database patterns for Spring Boot 4 with Spring Data JPA, Hibernate 7.1, Flyway, and HikariCP. ## When to Use - "database design" / "entity mapping" / "JPA query" - "N+1 problem" / "slow query" / "optimize database" - "migration" / "Flyway" / "schema change" - "connection pool" / "HikariCP" / "caching" --- ## Quick Reference: Common Problems | Problem | Symptom | Solution | |---------|---------|----------| | N+1 queries | Slow list endpoints, many SQL statements | `@EntityGraph`, fetch join, `@BatchSize` | | Lazy loading outside session | `LazyInitializationException` | Fetch in query, DTO projection, `open-in-view=false` | | Full table scan | Slow queries even on small filters | Add index on predicate columns | | Connection exhaustion | Timeouts under load | Tune HikariCP pool size | | Schema drift | App fails after deploy | Flyway validates schema at startup | | Stale cache | Users see outdated data | TTL eviction, `@CacheEvict` on writes | --- ## Entity Design ### Base Entity with Auditing ```java @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class AuditableEntity { @CreatedDate @Column(nullable = false, updatable = false) private Instant createdAt; @LastModifiedDate @Column(nullable = false) private Instant updatedAt; public Instant getCreatedAt() { return createdAt; } public Instant getUpdatedAt() { return updatedAt; } } ``` ### Relationships ```java // One-to-Many (Order →