-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datastore#save throws NPE if the entity returns hashCode that depends on @Version field #801
Comments
OK. This isn't really a Morphia issue. Here's what's going on. As your entity makes its way through the persistence logic, it's put in to a Map to track which entities morphia has seen so far. When it gets put in to the Map, it has a hash based on the final int versionHashCode = (id == null || version == null) ? 0 : version.hashCode(); This will at least ignore the version code when it's first saved. This however will have the same problem with subsequent saves because the hash value changes midprocess which is a bug in There's not a whole lot that Morphia can do if the hash value keeps changing from underneath it. I hope this helps. |
waiting for last known working version. |
Hi, Here are the results.
|
Perfect. Thanks. I'll dig into it.
|
Probable errant commit: 182ed32 |
I tracked it down. The code that extracted the generated _id value had been moved around in the lifecycle causing problems with how the test code was deciding when to include the version in the hashcode. I consolidated the code that pulled the new version number and the new _id value to be set "simultaneously" so that this scenario works again. |
I confirmed the fix. Thanks Justin:smile: |
I tested with Morphia v1.0.1 & Mongo Java Driver v3.0.2 on JDK 8u45.
NullPointerException
occurs both on Windows & MacOS.Morphia v0.105 works fine.
Repro code
Stacktrace
The text was updated successfully, but these errors were encountered: