Spring CRUD Generator v1.1.0 Updates
Spring CRUD Generator v1.1.0 bootstraps Spring Boot backends from YAML, adding validation, Redis caching fixes, OSIV control, and support for Spring Boot 3/4.
Join the DZone community and get the full member experience.
Join For FreeI’ve just released Spring CRUD Generator v1.1.0 — an open-source generator that helps you bootstrap a Spring Boot CRUD backend from a single YAML specification.
If you’ve built more than a couple of CRUD-heavy services, you’ve probably experienced the same pain points: repeating the same layers (entity, repository, service, controller), keeping consistent naming and structure across modules, and constantly adjusting boilerplate when requirements change. Spring CRUD Generator aims to reduce that overhead by letting you define your data model and project options once (in YAML) and generate a consistent project structure around it.
This release adds field-level validation, improves Redis caching, and fixes compatibility issues so the generator works reliably with Spring Boot 3 and Spring Boot 4. It also improves behavior when Open Session In View (OSIV) is disabled by adding EntityGraph support in generated resources.
What’s New in v1.1.0
1. Field Validation (fields.validation)
The headline feature in v1.1.0 is a new optional “validation” section inside each entity field definition. Instead of sprinkling validation rules manually throughout your DTOs and controllers after generation, you can now describe typical constraints directly in the YAML config and have the generator produce the appropriate validation-aware output.
This is useful for teams that want a single source of truth for model constraints. A YAML-driven validation model also makes it easier to review and evolve constraints alongside schema changes. For example, you can express “this field must be required” or “string length must be within a range” directly where the field is defined.
A notable addition in this release is support for regex-based validation via “pattern.” That’s a practical constraint for fields like passwords, identifiers, or custom-formatted strings.
It’s worth mentioning that the validation section is optional: if you don’t need it, you don’t have to add it, and your existing specs remain valid.
2. Cache and Redis Improvements
Caching is a common performance layer in CRUD systems, but it becomes tricky when you combine Redis serialization and Hibernate’s lazy-loaded associations.
This release includes two important caching-related improvements:
- The generator previously produced incorrect values for @Cacheable(value=...) in certain cases. That has been fixed, ensuring that cache names/values are generated consistently and correctly.
- Cache configuration has been updated to include HibernateLazyNullModule. This improves Redis caching behavior when Hibernate lazy-loaded entities are involved. In practice, it reduces the likelihood of serialization issues (or unexpected failures) when caching objects that contain lazily-loaded properties.
If your generator output is used in services that rely on Redis for caching, this update should make caching more stable and predictable.
3. Spring Boot 3 and 4 Compatibility
Another big part of this release is compatibility. The generator is now fully compatible with both Spring Boot 3 and Spring Boot 4.
In ecosystems like Spring, small changes between major versions can break builds, plugins, or code generation assumptions. Ensuring compatibility across versions is essential for teams that want to upgrade gradually (or maintain multiple services on different baselines). v1.1.0 addresses compatibility issues so you can use the generator reliably on either Spring Boot line.
4. OSIV Control + EntityGraph Support
Open Session In View (OSIV) is often considered an anti-pattern because it can hide N+1 query problems and produce unpredictable lazy-loading behavior in higher layers. Many teams disable it intentionally.
In v1.1.0, the generator introduces a new configuration entry:
additionalProperties.spring.jpa.open-in-view (default: false)
With OSIV disabled by default, the generated resources now include EntityGraph support to handle lazy relations more safely. The goal here is practical: avoid surprising LazyInitializationException scenarios without relying on OSIV. This approach also nudges generated projects toward better data-fetching discipline.
If your project still relies on OSIV, you can explicitly set it to true in the configuration. But the default aligns with a more defensive and production-friendly setup.
5. Improvements and Stability
Beyond features, v1.1.0 includes a set of improvements that make the project easier to maintain and more robust:
- Documentation has been updated to reflect the new fields.validation structure.
- Tests have been updated and fixed so they work correctly with the new validation model.
- The generator internals were refactored to improve readability and maintainability.
- A validation edge case was fixed: when min/max are not provided, the generator no longer throws a NullPointerException (NPE). This prevents configuration mistakes from turning into runtime failures during generation.
There is also an updated “full CRUD spec YAML” reference example in the repository. It existed before, but it has now been refreshed to include the new fields.validation configuration and the additionalProperties.spring.jpa.open-in-view setting. If you want to see the complete configuration surface area (not just a short snippet), that reference YAML is the best place to start.
Updated CRUD Spec YAML (Short Example)
The repository includes an updated full CRUD spec YAML reference example. Below is a shortened snippet that highlights the new and most important parts (validation + OSIV):
configuration:
database: postgresql
javaVersion: 21
springBootVersion: 4
cache:
enabled: true
type: REDIS
expiration: 5
openApi:
apiSpec: true
additionalProperties:
rest.basePath: /api/v1
spring.jpa.open-in-view: false
entities:
- name: ProductModel
storageName: product_table
fields:
- name: id
type: Long
id:
strategy: IDENTITY
- name: name
type: String
column:
nullable: false
unique: true
length: 10000
validation:
required: true
notBlank: true
minLength: 10
maxLength: 10000
- name: price
type: Integer
column:
nullable: false
validation:
required: true
min: 1
max: 100
- name: users
type: UserEntity
relation:
type: OneToMany
fetch: LAZY
joinColumn: product_id
validation:
required: true
minItems: 1
maxItems: 10
- name: UserEntity
storageName: user_table
fields:
- name: id
type: Long
id:
strategy: IDENTITY
- name: email
type: String
validation:
required: true
email: true
- name: password
type: String
validation:
required: true
pattern: "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$"
Tip: Check the repository’s full CRUD spec YAML example to see the complete supported configuration surface
Upgrade Notes
fields.validationis optional — add it only where needed.spring.jpa.open-in-viewdefaults tofalse. If your project relies on OSIV behavior, explicitly set it totrue.
If you build Spring Boot services frequently and want to reduce repetitive CRUD boilerplate, feel free to try the generator and share feedback. If you find the project useful, I’d really appreciate a star on the repository — it helps a lot and keeps the momentum going.
Repository: https://github.com/mzivkovicdev/spring-crud-generator.
Development continues, and more improvements are on the way. Thanks for the support!
Published at DZone with permission of Marko Zivkovic. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments