Entity variable apparently is never null