Everything you get
Practical generation. Production defaults.
CrudCraft turns annotated JPA entities into controllers, services, repositories and DTOs at compile time.
You keep full control over security, mapping and endpoints—without carrying a reflection-heavy runtime.
Generator
Code generation
The annotation processor scans your entities and writes the layers you would otherwise copy-paste (or let AI write):
Controller, Service, Repository, RequestDto, ResponseDto
(plus a Reference DTO) and a MapStruct Mapper. It fails at build-time so runtime stays predictable.
DTOs
Entity → DTOs
Generates XRequestDto
, XResponseDto
and XReferenceDto
.
Fields are selected via @Request
and @Dto
(with simplified
flag).
Bean Validation annotations are carried over; enum fields get OpenAPI @Schema(allowableValues)
.
Mapping
MapStruct mappers
Generates an interface XMapper
with fromRequest, update, patch,
toResponse and toSimplified. MapStruct compiles the implementation—no runtime reflection,
just fast, typed mappers.
Data
Repositories
Generates JpaRepository
+ JpaSpecificationExecutor
per entity.
QueryDSL support stays opt-in so the default stack remains lean.
Service
Service stubs
Your concrete service extends AbstractCrudService
and wires the repository + mapper.
Hook methods like postSave and preDelete let you enforce invariants or fix relationships.
HTTP
Controller stubs
Controllers extend AbstractCrudController
and expose GET/POST/PUT/PATCH/DELETE,
search and bulk endpoints based on your template. Security annotations are emitted when enabled.
DX
Editable stubs
When editable=true
, stubs are copied into your source tree once and never overwritten.
Add business logic freely while the base stays generated.
Operators
Rich operator set
EQUALS
, NOT_EQUALS
, CONTAINS
, STARTS_WITH
, ENDS_WITH
,
IN
, NOT_IN
, LT
, LTE
, GT
, GTE
,
BETWEEN
, IS_NULL
, IS_NOT_NULL
, size operators and more.
Spec
Specification first
We prioritize JPA Specification for broad compatibility and performance. QueryDSL can be added where it shines,
but the default path stays predictable and small.
Depth
Nested relations
Configure how deep relations are traversed for search with crudcraft.search.depth
.
Practical defaults avoid “SELECT * of the world” while keeping queries expressive.
Safety
Security
Add constraints where they belong. Endpoint access lives in policies, row-level access in a handler, and field-level
guards on DTOs. The generator emits the right glue so you can reason locally.
Endpoints
Policy-driven endpoints
Select a template (e.g. FULL, READ_ONLY, NO_DELETE) and/or include/omit methods.
When secure=true
, the controller is generated with @PreAuthorize
expressions from your policy.
Rows
Row-level security
Provide a RowSecurityHandler<T> to scope reads and writes—tenant fences, ownership checks,
or custom predicates/specifications that are always applied.
Fields
Field-level guards
Use @FieldSecurity(readRoles, writeRoles)
on DTO fields. Writes get filtered before persistence; reads are
redacted after mapping. The behavior is declarative and obvious in code review.
Engine
Runtime & performance
The runtime is intentionally small. Abstract base classes implement the common paths while your app stays in charge.
Minimal reflection, fail-fast behavior and measured hooks result in predictable throughput.
Services
AbstractCrudService
Implements CRUD, bulk, exists/count and both full and simplified listings. It composes the generated
Specification with row-security and delegates mapping to MapStruct.
HTTP
AbstractCrudController
Spring MVC endpoints with Pageable support and optional export. Generics are there for type safety; behavior stays boring on purpose.
Perf
Lean by design
Heavy lifting happens at build time. Runtime reflection is avoided on hot paths; metadata is cached; mapping is compiled.
The result: quick startup and stable latency.
Consistency
Fix/Clear helpers
Generated helpers ensure child↔parent pointers remain in sync after save and before delete.
Call them from service hooks for robust aggregates.
DTOs
Relation DTO mapping
Relation fields are mapped to the appropriate DTO type automatically—full or simplified—so API shapes stay consistent across aggregates.
Schema
Embedded & enums
Embedded types become embedded DTOs and enums expose their values in OpenAPI for great DX in Swagger/clients.
Beyond CRUD
Bulk, export & pagination
Ship the affordances real apps need: multi-record operations, count/exists probes, streaming exports and light-weight list views.
Batch
Bulk endpoints
/batch/create|update|patch|delete|find|exists
endpoints are available where useful. Prefer
saveAll semantics and consider per-item error reporting for large flows.
Export
CSV/JSON/XLSX
Stream exports with sensible limits to protect your app. Choose allowed formats and row caps in configuration.
Lists
Pagination & simplified views
Pageable endpoints with “simplified” DTO projections for list pages keep payloads small and UIs snappy.
Bean Validation
Carry constraints
Bean Validation annotations are copied to request/response DTOs, keeping invariants intact at the boundary.
Errors
Uniform error responses
A small exception handler produces consistent JSON for validation failures, not-found errors and more.
Auto-config
Starter module
Minimal Spring Boot auto-config (properties + exception handler). No hidden frameworks.
Props
Tunable behavior
Tweak crudcraft.search.depth
, export limits and template defaults at the application level.
Tooling
Editable-stubs tool & utilities
A one-time copier preserves your edits; shared codegen utilities centralize naming and file I/O to avoid duplication.