Skip to content

Second Tutorial Part 1: Compile Time Java Code Generation

Laurent Hasson edited this page Oct 16, 2019 · 16 revisions
Previous Main Next
Main Part 2 -->

This Tutorial

In the First Tutorial, we explored the modeling capabilities of Tilda and the ability to iteratively define tables and complex views. For some projects, this may be all you need to do: maintain a rich schema, produce documentation, enjoy automated iterative deployments with automated migrations. This is a simple way to use Tilda with at the core simple managed SQL-based assets (DDL files). This is applicable for example for data warehouse projects or schemas in general where data population and access is done via tools (for example, an ETL suite such as Pentaho Kettle to populate the database and a reporting tool such as Tableau to display data).

For some other projects however, you may want to access the data through an application, for example, a Java-based Web application. In that respect, Tilda is similar to other frameworks such as Hibernate or MyBatis, but with some key differences:

  • Tilda is model-driven from the start as illustrated by the First Tutorial.
  • Tilda generates transparent Java-based assets that do not obfuscate your model or your SQL needs.
  • Tilda can reverse engineer schemas and generate models, which in turn will be used to stand up Java applications.
  • Tilda generates all your POJOs and JDBC wrapper code from the model: no need to write tedious access code to stand up an application against a model.
  • Documentation and migration are built in from the start.
  • Logging and performance monitoring are built in from the start.
  • Tilda understands JSON or CSV and patterns such as "sync" and thus is a good solution for web services that manage sync'ed data sets from mobile or offline applications for example.
  • Tilda generates compile-time artifacts which makes iterative development and model refactoring a natural part of the development process, aided with standard features of your favorite IDE and compiler.

In this tutorial, we'll cover the basic architecture of the Java code Tilda generates and how to use them, in particular:

  • Reading and writing from tables
  • Reading from views
  • Methods of access via indices and queries
  • Custom where-clauses
  • Record Processors
  • Servlet bindings
  • Data export capabilities in JSON and CSV
  • Custom queries
  • Code customization with hidden fields and pre-write/post-read handlers.

We expect someone to take about 60mn to get through this 10-parts material, and an accompanying video that shows an actual development session. The parts are:

We aim to demonstrate the power of Tilda and highlight through examples what we believe are the strongest points of the framework:

  • The 'T' in Tilda stands for 'Transparent' and the SQL and Java assets it generates should be mostly obvious to someone who understands SQL and basic JDBC, but not critical in using the framework.
  • The 'I' in Tilda stands for 'Iterative' and the development process supported by the framework encourages an agile approach to development:
    • The Migrate utility automates many of the tasks that are typically handled by a DBA
    • Tilda models are living breathing models
    • The structure of how models are defined in JSON enable much more team concurrency in maintaining the model
    • The compile-time nature of the generated code helps promote refactoring patterns key to iterative agile development.
  • Tilda is performance-conscious and implements many patterns that can handle large datasets and drives JDBC APIs at the lowest level.
  • Tilda is easy to adopt by a junior team of Java engineers with modest database skills.

We recognize that Tilda is a very young project and hope to also demonstrate that the risk of adopting it is low because all its assets are plain SQL and Java and could easily be used mixed in another environment.

Pre-requisites

You should have your development environment ready. See Getting Started.

  • Have installed on your system Java, PostgreSQL, Eclipse and possibly Apache Tomcat.
  • Have your Eclipse workspace configured and initialized with a base project.
  • Have set up the tutorial project.

This second tutorial also builds upon the scenario explained through the First Tutorial and therefore, you should be familiar with it as well.

Clone this wiki locally