Fix fatal errors on _joinData

Fix fatal errors caused by un marshalled _joinData properties. The BelongsToMany association was assuming that this property would always contain an entity, which it doesn't.

I have also updated the associations to typehint against the interface instead of the concrete type.

Refs #5130