Fixes NPE when entity not managed
Merge pull request #116 from bric3/fix-npe-for-unmanaged-entities

Fixes NPE when entity not managed