December 2009
Intermediate to advanced
380 pages
9h 2m
English
Building an object-relational database mapping is an excellent use of code generation. In this section, we’re going to build one component of such a mapping by generating SQL schemas from Java class definitions. To keep things simple, we’ll restrict ourselves to fields whose Java types maps easily to SQL types (such as integers, strings, floats, doubles, and Date objects).
To build this generator, we’re going to use Java’s reflection API as an input model and create a nested template hierarchy as we did in the previous section. This application is going to require some new skills, though. We have to get comfortable sifting and filtering the input model and then applying templates to that data. Since ST is a ...