Chapter 16: Tackling Aliases and SQL Templating
This chapter covers two important topics that sustain your road to becoming a jOOQ power user: aliases and SQL templating.
The first part of this chapter tackles several practices for aliasing tables and columns via the jOOQ DSL. The goal of this part is to make you comfortable when you need to express your SQL aliases via jOOQ and to provide you with a comprehensive list of examples that cover the most common use cases.
The second part of this chapter is all about SQL templating or how to express SQL when the jOOQ DSL cannot help us. There will be rare cases when you'll have to write plain SQL or combine DSL and plain SQL to obtain some corner cases or vendor-specific features.
In this chapter, we will cover the following main topics:
- Expressing SQL aliases in jOOQ
- SQL templating
Let's get started!