A Bayesian hierarchical approach to galaxy–galaxy lensing