Converted to jOOQ library for SQL building.
significantly simplifies building complex parameterised querys with
variable numbers of parameters.