Migrate to StringTemplate for query generation.