common-codes

Define domain code enums implementing CommonCode with EnumType.STRING for JPA persistence.

Updated Jan 11, 2026
One-click install
npx skills add https://github.com/gykk16/spring-skeleton --skill common-codes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: common-codes
Source: https://github.com/gykk16/spring-skeleton/tree/main/.omc/skills/common-codes
Command: npx skills add https://github.com/gykk16/spring-skeleton --skill common-codes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the inconsistency and potential for errors in representing domain-specific codes within an application by establishing a standardized interface and best practices for enum definitions and JPA persistence.

Core Features & Use Cases

  • Standardized Enum Contract: Ensures all domain codes implement the CommonCode interface, providing consistent code and description access.
  • JPA Persistence Best Practices: Enforces the use of EnumType.STRING for enums in database entities to prevent data corruption.
  • Use Case: When defining an OrderStatus enum, this Skill ensures it implements CommonCode and is correctly persisted as a string in the database, preventing issues if the enum order changes.

Quick Start

Define a new enum for payment methods, ensuring it implements the CommonCode interface.

Frequently Asked Questions about common-codes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why should I use EnumType.STRING for JPA persistence instead of ordinal mapping?

Using EnumType.STRING for JPA persistence prevents data corruption by storing the enum's name as a string, ensuring database records remain valid even if the enum order changes.

How do I standardize domain code enums in Kotlin to ensure consistent access?

You standardize domain code enums by implementing a CommonCode interface, which provides a consistent contract for accessing code and description fields across all domain definitions.

What are common pitfalls when mapping Kotlin enums to database entities?

Common pitfalls include using ordinal mapping which breaks when enum order changes, and missing column length specifications, both of which can cause data truncation or persistence errors.

Can I integrate domain code enums with REST Docs?

Yes, the standardization approach covers REST Docs integration, allowing you to document the code and description fields of enums implementing the CommonCode interface in your API outputs.

What is the best way to define an OrderStatus enum for JPA persistence?

The best way is to implement the CommonCode interface for your OrderStatus enum and annotate the entity field to persist as EnumType.STRING, preventing issues if the enum order changes.