detach fix, npe fix i entitymanager
Merge pull request #153 from asimarslan/entity-manager

detach fix, npe fix in entitymanager