[JAVA-75] Generated ObjectID not unique Created: 06/Jan/10 Updated: 13/Jan/10 Resolved: 06/Jan/10 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 1.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Max Dessì | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
MacOSX 10.6.2 JDK 1.6 |
||
| Description |
|
In a test class the following code List<DBObject> users = new ArrayList<DBObject>(); produce the same ObjectID for each userXXX inserted I see in the driver the "algorithm": Suggestion: public static String calculateUniqueId() { I have ids different for each userXXX in the same test where ObjectID fails |
| Comments |
| Comment by Max Dessì [ 07/Jan/10 ] |
|
I don't have sharp eye like you |
| Comment by Kristina Chodorow (Inactive) [ 07/Jan/10 ] |
|
Here are your ids (spaces added for emphasis): 4b4599fe45d2ba538 9 58a21c |
| Comment by Max Dessì [ 07/Jan/10 ] |
|
No, the second example is more explicit but the logic it's the same: mapOne => userOne.toMap() repo.getCollection().insert(users) => datastore.getDB().getCollection("usersTest").insert(users) I have the same problem if replace the list insert with three DBObject insert: datastore.getDB().getCollection("usersTest").insert(new BasicDBObject(one)); How can obtain dirfferent ids ? |
| Comment by Eliot Horowitz (Inactive) [ 07/Jan/10 ] |
|
Those are differnt |
| Comment by Max Dessì [ 07/Jan/10 ] |
|
Eliot, this is example code: @Test Map mapTwo = new HashMap(); Map mapThree = new HashMap(); List<DBObject> users = new ArrayList<DBObject>(); datastore.getDB().getCollection("usersTest").insert(users); DBCursor cursor = getDB().getCollection("usersTest").find(); getDB().getCollection("usersTest").drop(); and produce the output: id:4b4599fe45d2ba538958a21c name:Jack Surname:Folla |
| Comment by Eliot Horowitz (Inactive) [ 06/Jan/10 ] |
|
i tried to find any issue with the code and tried your snippet but can't find anything wrong. If you can send a full program that displays the error, can take a look. |