HHH-9357 Fix type() with joined inheritance and discriminator column (4.3).

Same as PR #797 but on branch 4.3.