← ClaudeAtlas

jpa--postgresqllisted

Provides expert knowledge of JPA entity design, relationship mapping, Flyway migrations, and PostgreSQL-specific optimizations.
lgzarturo/codeconductor · ★ 0 · API & Backend · score 76
Install: claude install-skill lgzarturo/codeconductor
# JPA + PostgreSQL ## Entity Design ### Primary Keys Use UUIDs. Do not use auto-increment integers as public-facing identifiers. ```kotlin @Entity @Table(name = "users") class User( @Id @GeneratedValue(strategy = GenerationType.UUID) val id: UUID = UUID.randomUUID(), @Column(name = "email", nullable = false, unique = true, length = 255) var email: String, @Column(name = "name", nullable = false, length = 100) var name: String ) ``` UUID generation strategy `GenerationType.UUID` is available in Hibernate 6+ (Spring Boot 3+). For earlier versions, use `@UuidGenerator` from Hibernate or generate manually. ### Auditing Enable automatic timestamp management with Spring Data auditing. ```kotlin // Enable in main application class or a @Configuration class @EnableJpaAuditing @SpringBootApplication class Application // Base class for auditable entities @MappedSuperclass @EntityListeners(AuditingEntityListener::class) abstract class AuditableEntity { @Column(name = "created_at", nullable = false, updatable = false) @CreatedDate lateinit var createdAt: Instant @Column(name = "updated_at", nullable = false) @LastModifiedDate lateinit var updatedAt: Instant } // Entity extends the base class @Entity @Table(name = "users") class User( @Id @GeneratedValue(strategy = GenerationType.UUID) val id: UUID = UUID.randomUUID(), @Column(name = "email", nullable = false, unique = true) var email: String, var name