[JAVA-758] Write concern is behaving unexpectably Created: 12/Feb/13 Updated: 13/Feb/13 Resolved: 13/Feb/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.9.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Brice Laurencin | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver, java, writeResult | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
$ uname -a |
||
| Attachments: |
|
| Description |
|
Hi, The first save to a DBCollection seems to be failing, writeResult.getN() being != 1, but in fact, it does save the object, a subsequent find() proves it (see the attache test class, the method theTest). After a seemingly failled save, a second save actually return writeResult.getN() being == 1 (see theSecondTest). Did I do/understood something wrong? Thanks for your precious help! |
| Comments |
| Comment by Brice Laurencin [ 13/Feb/13 ] |
|
On this very test, it is an insert both times. Anyway, I worked arround this behavior, thanks for your time! |
| Comment by Jeffrey Yemin [ 13/Feb/13 ] |
|
You can use that to determine whether the save call ended up inserting a new document or updating an existing one. n = 0 is an insert, n = 1 is an update |
| Comment by Brice Laurencin [ 13/Feb/13 ] |
|
Thanks for your quick reply! But then I don't get why the second call returns 1. |
| Comment by Jeffrey Yemin [ 12/Feb/13 ] |
|
I believe that n is not set on inserts, only updates and removes, since it's only then that you don't necessarily know how many documents were updated/removed. If the insert/save failed, an exception will be thrown. |