Added the buildTenantQuery method to the trait.