What does this skill do?

The Patrones JPA Spring Boot Skill generates structured and optimized Java code for Spring Boot applications: secure, auditable entities; efficient repositories free from the N+1 problem through JOIN FETCH and DTO projections; and robust transaction and infrastructure configurations using HikariCP and Flyway or Liquibase migrations.

Entity Design
Define @Entity classes with @Table, column constraints, explicit indexes, and auditing using @CreatedDate and @LastModifiedDate.
Relationship Management
Configure @OneToMany, @ManyToOne, and @ManyToMany with `mappedBy` and `FetchType.LAZY` by default to avoid unnecessary loading.
Preventing the N+1 Problem
Implement repositories using @Query and JOIN FETCH to retrieve related data in a single query, and DTO projections for lightweight read routes.
Transactions and Infrastructure
Annotate services with @Transactional(readOnly = true) for read operations, configure HikariCP, and use Flyway or Liquibase for schema migrations.

Usage examples

🏗️ Organization Design
Design a JPA entity for a `markets` table with a unique index on the `slug` column, date auditing, and a status enum.
⚡ Repository without N+1
Create a repository that retrieves a Market along with its positions in a single query using JOIN FETCH and that supports pagination by state.
🔗 Relationship with LAZY
Define a @OneToMany relationship between MarketEntity and PositionEntity with FetchType.LAZY and the correct mappedBy.
🔧 Service Transactions
Implement a service method with @Transactional that updates the status of a Market and throws an EntityNotFoundException if it does not exist.

Features

Audited, Secure Institutions Generates @Entity classes with column constraints, explicit indexes, and @CreatedDate and @LastModifiedDate audit fields.
Optimized Relationships Configure @OneToMany, @ManyToOne, and @ManyToMany with `mappedBy` and `FetchType.LAZY` by default to avoid unnecessary loads.
Preventing the N+1 Problem Use @Query with JOIN FETCH and DTO projections for lightweight read paths and efficient single-pass queries.
Transaction Control Annotate service methods with @Transactional and set reads to readOnly = true to enable Hibernate optimizations.
Infrastructure and Connection Pool Set HikariCP in the application properties and use Flyway or Liquibase for migrations instead of automatic DDL generation.

Frequently asked questions

It is not necessary to generate the code. The skill produces entities, repositories, and configurations that are ready to be integrated into an existing or new Spring Boot project.
Yes. It generates repositories using @Query and JOIN FETCH to retrieve related data in a single query, and recommends DTO projections for lightweight read routes.
Yes. The skill configures the HikariCP connection pool in the application properties and recommends Flyway or Liquibase instead of automatic DDL generation.
Yes. The generated code provides a solid foundation that you can adapt to the specific needs of your Spring Boot project.
JPA Spring Boot Patterns — Modeling and Optimization with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.