I just got the same problem with Hibernate. The answer to the original question is why.
But to talk about the solution, I just use the @PostLoad method, so inside the Embedder class something like:
@PostLoad private void initData() { if(notAutoInstantiated == null) { notAutoInstantiated = new NotAutoInstantiated(); } }
Update:
A warning! The top code works, but has an unexpected side effect! As soon as you load your null pointer object from the database, it will be marked as dirty due to this mail loading code! In my case, these side effects lead to the SQL update command from the stream, which should only load data and hours of searching for this error!
Martin metz
source share