/micronaut-standards:entity-designfrom Micronaut Standards
OneLiteFeather's JPA/Micronaut Data entity conventions for Micronaut REST APIs — entities as a pure persistence layer with no Bean Validation annotations, the internal-UUID-vs-external-identifier pattern, custom AttributeConverters for complex column types, and why entities are plain Java beans rather than records or Lombok classes. Use this whenever adding or reviewing a database/entity/ class in a Micronaut backend. For where entity validation actually lives, see the dto skill; for the optional pattern of publishing entities from a separate Maven module instead of keeping them in the backend, see references/separate-model-module.md in this skill.
Ships in Micronaut Standards. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Entities in database/entity/ are a pure persistence layer — nothing more. They map to a table, and
that is their entire job. Validation, conversion, and API shape all live elsewhere (see dto and
response-modeling); an entity that also carries @NotBlank/@Size annotations or a toDto() method
is doing someone else's job.
// database/entity/FontEntity.java — correct: no @NotBlank, @Size, etc. here
@Entity
@Table(indexes = { @Index(columnList = "uiName") })
public class FontEntity {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
private String uiName;
private String texturePath;
// ...
public FontEntity() {
} // required by Hibernate
public FontEntity(UUID id, String uiName, String texturePath /*, ... */) {
this.id = id;
this.uiName = uiName;
this.texturePath = texturePath;
}
// getters and setters
}
The DTO (see dto) is the single source of truth for validation. Putting @NotBlank on both the DTO
field and the entity field means the same rule can drift out of sync between the two — one gets updated,
the other doesn't, and now the entity silently accepts data the DTO would have rejected (or vice versa).
Keep it in exactly one place: the DTO.
When an entity represents something that also has an identifier from an external system (a Minecraft
player's Mojang UUID, a third-party API's own ID), keep the entity's own primary key separate from that
external identifier instead of reusing it as the @Id:
@Entity
@Table(indexes = {
@Index(columnList = "playerUuid"),
@Index(columnList = "playerName")
})
public class PlayerEntity {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id; // internal primary key
private UUID playerUuid; // external identifier (Mojang UUID) — indexed, not the PK
private String playerName;
}
This decouples the row's identity from an identifier the application doesn't control — if the external system's ID scheme ever needs to change or be re-issued, the entity's own primary key and every foreign key pointing at it are unaffected.
For a column type Hibernate doesn't map natively — a Locale, a Map<String, Object> stored as JSON —
write a JPA AttributeConverter rather than serializing it ad hoc in application code:
@Converter
public class LocaleAttributeConverter implements AttributeConverter<Locale, String> {
@Override
public String convertToDatabaseColumn(Locale locale) {
return locale == null ? null : locale.toLanguageTag();
}
@Override
public Locale convertToEntityAttribute(String dbData) {
if (dbData == null) return Locale.ENGLISH;
try {
return Locale.forLanguageTag(dbData);
} catch (IllformedLocaleException e) {
return Locale.ENGLISH; // fall back rather than fail the whole entity load
}
}
}
For a JSON column, combine @Convert with @JdbcTypeCode(SqlTypes.JSON) (Hibernate 6):
@Convert(converter = MapStringObjectConverter.class)
@JdbcTypeCode(SqlTypes.JSON)
private Map<String, Object> metadata;
Apply the converter on the field with @Convert(converter = LocaleAttributeConverter.class), and give
it a sensible fallback value (as above, Locale.ENGLISH) rather than throwing and failing the whole
entity load over one malformed value — a @ColumnDefault on the column is a reasonable second line of
defense for the same default at the database level.
Entities are classic Java beans: a no-args constructor (required by Hibernate to instantiate the entity
via reflection before populating fields), an all-args constructor for convenience, and plain
getters/setters. No Lombok, no records. Records are reserved for DTOs (see dto/response-modeling) —
an entity's mutability and Hibernate's reflection-based instantiation are exactly what a record's
immutable, canonical-constructor-only shape is unsuited for.
references/separate-model-module.md — the optional pattern of publishing entities from a separately
versioned Maven module instead of keeping them inside the backend, for projects with more than one
consumer of the same data model.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub onelitefeathernet/onelitefeather-claude-marketplace --plugin micronaut-standards14 skills in this plugin
/configurationOneLiteFeather's convention for typed application configuration in a Micronaut REST API — one @ConfigurationProperties class per functional area in a dedicated config/ package, instead of ad-hoc properties scattered across the application entry point. Use this whenever a Micronaut backend needs a new piece of externalized configuration (a feature flag, an external service URL, a limit/threshold) and you're deciding where the corresponding Java type should live./dependency-managementOneLiteFeather's Gradle/Micronaut dependency-management conventions for REST API backends — the Micronaut Application and AOT plugins, reading the Micronaut version from gradle.properties instead of hardcoding it, the mn.* platform catalog, the private OneLiteFeather Maven repo, and the optional CycloneDX SBOM plugin. Use this whenever setting up or editing a Micronaut backend's build.gradle.kts/settings.gradle.kts. For the general OneLiteFeather Gradle/BOM mechanics that apply beyond Micronaut (private repo credential split, Java toolchain pattern), see minestom-knowledge:gradle/boms instead. For observability, database-migration, Testcontainers, and security dependencies specifically, see the observability, liquibase, testcontainers, and security skills — this skill only lists that those dependencies exist and where to look, not their coordinates; the one exception is structured-logging dependencies (Logstash encoder, OpenTelemetry MDC appender), whose coordinates live directly in this skill since `logging` covers only their usage./dtoOneLiteFeather's request-DTO conventions for Micronaut REST APIs — records with @Serdeable/@Introspected, one shared Create/Update DTO controlled by JSR-380 validation groups instead of separate DTO types per action, and entity conversion methods living on the DTO itself. Use this whenever adding a new request body type to a Micronaut controller. For the response side (success/error modeling), see the response-modeling skill; for endpoint-level OpenAPI documentation, see openapi — this skill covers only the incoming request DTO and its own field-level @Schema annotations./exception-handlingOneLiteFeather's global exception-handling convention for Micronaut REST APIs — exactly one org-wide ExceptionHandlerAdvice that maps exception types to the correct HTTP status code and returns the shared ErrorResponse type from response-modeling, plus dedicated domain exception classes instead of generic RuntimeExceptions. Use this whenever adding a new failure case a Micronaut backend needs to report, or reviewing an existing global exception handler that maps everything to one status code. This is an explicit correction of a mapping-everything-to-404 pattern seen in an early reference implementation — status-code mapping by exception type is mandatory./liquibaseOneLiteFeather's mandatory Liquibase database-migration convention for Micronaut REST APIs — always XML changelogs (never YAML/SQL/JSON), the master-changelog-plus-versioned-files structure, and why this replaces Hibernate's hbm2ddl.auto=update. Use this whenever a Micronaut backend needs a schema change, or when reviewing a project still relying on hbm2ddl.auto=update for schema management. For verifying a changelog actually works against both MariaDB and PostgreSQL, see the testcontainers skill./loggingOneLiteFeather's logging conventions for Micronaut REST APIs — one SLF4J logger per class with no exceptions, structured JSON logging with OpenTelemetry trace/span correlation, log-level guidelines, and what must never be logged (PII, secrets, full request bodies). Use this whenever adding a new class that should log something, or reviewing an existing controller/service for inconsistent logging. For the Gradle dependencies and the metrics/tracing infrastructure this logging setup correlates with, see dependency-management and observability.