[WIP] Fixed targetEntity masking in doctrine 2.4

Not sure if its the right way to do it. I have not fully tested it in my app. For now just take this as a notice.