<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:54:22 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-1340] DBCollection.save(DBObject jo) method adds new document even if the same _id already exists</title>
                <link>https://jira.mongodb.org/browse/JAVA-1340</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;The save method adds another document with the same _id, for example 53dc0bf6c9d224c98f743a4e.&lt;/p&gt;

</description>
                <environment>Windows 7 &lt;br/&gt;
MongoDB 2.4.9&lt;br/&gt;
MongoDB Java Driver 2.11.3</environment>
        <key id="150543">JAVA-1340</key>
            <summary>DBCollection.save(DBObject jo) method adds new document even if the same _id already exists</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="dvohra">deepak vohra</reporter>
                        <labels>
                    </labels>
                <created>Fri, 1 Aug 2014 22:08:01 +0000</created>
                <updated>Sun, 3 Aug 2014 00:14:49 +0000</updated>
                            <resolved>Sun, 3 Aug 2014 00:14:49 +0000</resolved>
                                    <version>2.4</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="679743" author="jeff.yemin" created="Sun, 3 Aug 2014 00:14:38 +0000"  >&lt;p&gt;Oh, I see. You&apos;re using the String value of the ObjectId in rowUpdate.  Try:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        rowUpdate.put(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;_id&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; ObjectId(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;53dc0bf6c9d224c98f743a4e&quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;));&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;instead.&lt;/p&gt;</comment>
                            <comment id="679571" author="dvohra" created="Sat, 2 Aug 2014 13:43:09 +0000"  >&lt;p&gt;//Add a row.&lt;br/&gt;
DBObject row1 = new BasicDBObject(&quot;col1&quot;, &quot;val1&quot;).append(&quot;col2&quot;, &quot;val2&quot;);&lt;br/&gt;
coll.insert(row);&lt;/p&gt;

&lt;p&gt;//Obtain _id from the array output&lt;br/&gt;
row1 = coll.findOne();&lt;br/&gt;
System.out.println(row1); //for example _id is 53dc0bf6c9d224c98f743a4e&lt;/p&gt;


&lt;p&gt;//Query row to update&lt;br/&gt;
BasicDBObject dbObjectUpdate = new BasicDBObject();&lt;br/&gt;
dbObjectUpdate.put(&quot;col1&quot;, &quot;val1&quot;);&lt;br/&gt;
dbObjectUpdate.put(&quot;col2&quot;, &quot;val2&quot;);&lt;br/&gt;
DBObject rowUpdate = coll.findOne(dbObjectUpdate);//The row with _id 53dc0bf6c9d224c98f743a4e gets fetched&lt;/p&gt;


&lt;p&gt;//Set updated values for col1 and col2&lt;br/&gt;
rowUpdate.put(&quot;_id&quot;, &quot;53dc0bf6c9d224c98f743a4e&quot;);&lt;br/&gt;
rowUpdate.put(&quot;col1&quot;, &quot;val1_Updated&quot;); &lt;br/&gt;
rowUpdate.put(&quot;col2&quot;,&quot;val2_Updated&quot;); &lt;/p&gt;

&lt;p&gt;//Save updated row&lt;br/&gt;
coll.save(rowUpdate); &lt;br/&gt;
//new document with _id 53dc0bf6c9d224c98f743a4e gets added even though same _id exists&lt;/p&gt;</comment>
                            <comment id="679356" author="jeff.yemin" created="Sat, 2 Aug 2014 00:48:58 +0000"  >&lt;p&gt;Hi Deepak,&lt;/p&gt;

&lt;p&gt;I&apos;m not at all sure what you mean, as _id is unique within a MongoDB collection.  Can you provide an example that shows exactly what you&apos;re seeing.&lt;/p&gt;


&lt;p&gt;Regards,&lt;br/&gt;
Jeff&lt;/p&gt;
</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hs11q7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>130598</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>