From XML Models to Java Persistence Code
Historical note: This article documents an earlier TeaQL generation target. Early versions emitted backend templates, UI pages, mobile clients, and service scaffolding directly into application workspaces. Modern TeaQL has moved to a clearer boundary: generation produces versioned libraries, deterministic business APIs, query DSLs, and runtime capabilities that applications consume as artifacts. This is more friendly to AI-assisted coding and DevOps because AI agents can focus on business workflows, integrations, tests, and product behavior, while generated capabilities are reviewed, tested, published, upgraded, and rolled back through normal dependency and release pipelines.
The first useful shape of the generator was not a UI scaffold. It was a persistence scaffold.
Looking at the code changes, the core work concentrated around FieldDescriptor, ObjectDescriptor, CMRField, Java POJO templates, JDBC mapper templates, DAO implementations, SQL templates, and manager methods. That tells a clear story: the generator was learning to convert a domain description into an executable Java data layer.
Generated Java Object Model
The object templates started to produce more than plain fields:
- typed Java members from model fields
- constants for field names and table columns
- generated
toString, JSON serialization, and null-safe formatting - parent references and child reference lists
- version fields for optimistic updates
The important shift was that the generated entity became a stable contract. DAO, mapper, manager, serializer, and JSP snippets could all depend on the same metadata.
DAO, Mapper, and Manager Layers
The generator added separate templates for:
- DAO interface
- JDBC template implementation
- row mapper
- load and save helpers
- manager interface
- manager implementation
- manager exceptions
This separation mattered because it made generated code patchable by layer. SQL mapping problems could be fixed in mapper templates. Business entry points could evolve in manager templates. Persistence behavior could change without rewriting the domain model.
Multi-Database SQL Output
The early templates included MySQL, then added MSSQL support. Even at this stage, SQL was treated as generated infrastructure, not handwritten project code.
That design became a recurring theme: database differences should live behind generator templates and runtime helpers, while application code talks to generated typed APIs.
Relationship Handling
The generator also started handling parent and child relationships:
- loading referenced objects
- saving object graphs without duplicating unchanged rows
- ordering fields deterministically
- producing mapper code for references
This was the beginning of TeaQL's later object-graph save model. The early code was still template-heavy, but the direction was already visible: describe the domain once, then generate the repetitive persistence surface.
