Skip to main content

Code Generation

Overview​

ElastiCORE automatically generates complete Spring Boot application code based on DSL (model/*.yml) definitions.

Code Generation Command​

./gradlew elcore

This command parses the DSL definitions and automatically generates the following code:

  • Entity: JPA entity classes
  • DTO: Data transfer objects
  • Repository: Spring Data JPA repositories
  • Service: Service layer
  • Controller: REST API controllers (when @expose is used)
  • SearchDTO: Search condition DTOs (when @expose, @service, or @searchable is used)
  • Q classes: Specification-based dynamic queries
  • Port Interface: External system communication interfaces
  • Test Code: JUnit 5-based unit tests (when testCode.enabled: true is configured)

Generation Process​

1. DSL Parsing
Read blueprint/{domain}/*.yml files
↓
2. Model Validation
Grammar validation, referential integrity checks
↓
3. Code Generation
Generate Java source using the template engine
↓
4. File Output
Write files to package paths based on namespace configuration

Generation Modes​

The code generated depends on the mode setting in env.yml:

ModeGenerated Items
jpaEntity, DTO, Repository, Service, Controller
mongoMongoDB Document, Repository, Service
umlMermaid diagrams (deprecated)
pxPX platform integration code
config:
mode: jpa # JPA mode
# mode: jpa,uml # Multiple modes supported

Regeneration Rules​

One-time Generation (Default)​

If a generated file contains a marker comment, it will not be regenerated:

/*
* No longer managed by ElastiCORE. You may modify as needed,
* but retain the marker for traceability.
*/

Forced Regeneration​

Delete the file and then run ./gradlew elcore to regenerate it.

tip

When regeneration is needed, make sure to back up existing files before deleting them. Custom code may be lost.

Next Steps​