| I would prefer it if an NPE never was expected behavior (unless documented in a public API, maybe). At least an IllegalStateException could be thrown instead explaining some context, or having a unique message that can easily be found by searching on the web. Ideally it would have a message like "Lazy member of deleted entity cannot be fetched", but anything more technical and generic would also serve. In my case though, the purpose was to create an event that the entity has been deleted, which involved logging the serialized contents of the entity. And this happens in postRemove, so the code cannot work with the state from before delete. However I guess we do not need to log the full entity anyway, so I can find some better solution on my own. I still would recommend wrapping that NPE though, but I'll leave that to your wisdom. |