DEV Community

Marko
Marko

Posted on

Spring CRUD Generator v1.1.0: Field Validation, Better Redis Caching & Spring Boot 3/4 Compatibility

I just released Spring CRUD Generator v1.1.0

This version introduces field-level validation, improves Redis caching, and fixes compatibility issues so the generator now 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.

Repository: https://github.com/mzivkovicdev/spring-crud-generator


What’s new in v1.1.0

Field validation (fields.validation)

You can now configure validation rules directly in entity fields using a new optional validation section (required/not-null, length/range constraints, patterns, and collection size limits).

Regex validation is supported via pattern.

Cache & Redis improvements

  • Fixed generation of @Cacheable(value=...) values.
  • Added HibernateLazyNullModule to improve Redis caching behavior with Hibernate lazy-loaded entities.

Spring Boot 3 & 4 compatibility

Resolved compatibility issues — the generator is now fully compatible with Spring Boot 3 and Spring Boot 4.

OSIV control + EntityGraph support

  • New configuration entry: additionalProperties.spring.jpa.open-in-view (default: false).
  • When OSIV is disabled (recommended), generated resources use EntityGraph to handle lazy relations safely.

Improvements & stability

  • Documentation and tests updated for the new validation model.
  • Refactored generator internals for readability and maintainability.
  • Fixed an NPE edge case when min/max validation values are not provided.

Updated CRUD spec YAML (short example)

The project includes an updated full CRUD spec YAML reference example. Below is a shortened version 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,}$"
Enter fullscreen mode Exit fullscreen mode

Upgrade notes

  • fields.validation is optional — add it only where needed.
  • spring.jpa.open-in-view defaults to false. If your project relies on OSIV behavior, explicitly set it to true.

If you find this project useful, I’d really appreciate a star on the repo — it helps a lot and keeps the momentum going.

Development continues, and more improvements are on the way. Thanks for the support!

Top comments (0)