Fix to use custom join table in habtm

Fixes #14824