Use knowledge of entity in SQL gen