<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:54:12 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-1270] Class WriteResult Method getN() always return 0</title>
                <link>https://jira.mongodb.org/browse/JAVA-1270</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;DBObject user = new BasicDBObject();&lt;br/&gt;
user.put(&quot;name&quot;, &quot;hoojo&quot;);&lt;br/&gt;
user.put(&quot;age&quot;, 23);&lt;br/&gt;
WriteResult wr = dbCollection.insert(user);// dbCollection.save(user);&lt;/p&gt;

&lt;p&gt;method wr.getN() return 0 both with insert and save,&lt;br/&gt;
but the data save success.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Reporter&lt;/b&gt;: luoch&lt;br/&gt;
&lt;b&gt;E-mail&lt;/b&gt;: &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;mailto:luoch668@163.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;luoch668@163.com&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/mail_small.gif&quot; height=&quot;12&quot; width=&quot;13&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description>
                <environment>my environment : &lt;br/&gt;
mongodb used : mongodb-win32-x86_64-2008plus-2.6.1&lt;br/&gt;
java environmen t: mongo-java-driver-2.12.2.jar&lt;br/&gt;
springMVC 3.2&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
*Location*: &lt;a href=&quot;http://www.mongodb.org/about/support/&quot;&gt;http://www.mongodb.org/about/support/&lt;/a&gt;&lt;br/&gt;
*User-Agent*: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36&lt;br/&gt;
*Screen Resolution*: 1600 x 900&lt;br/&gt;
*repo*: mongodb-www-about&lt;br/&gt;
*source*: support&lt;br/&gt;
</environment>
        <key id="141251">JAVA-1270</key>
            <summary>Class WriteResult Method getN() always return 0</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                                <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="xgen-internal-docs">Docs Collector User</reporter>
                        <labels>
                            <label>collector-298ba4e7</label>
                    </labels>
                <created>Tue, 10 Jun 2014 06:23:58 +0000</created>
                <updated>Tue, 23 Jun 2015 15:35:11 +0000</updated>
                            <resolved>Tue, 23 Jun 2015 15:35:11 +0000</resolved>
                                                                    <component>Documentation</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="948175" author="jeff.yemin" created="Tue, 23 Jun 2015 15:35:11 +0000"  >&lt;p&gt;In the new CRUD API introduced in 3.0, the insertOne/insertMany methods on MongoCollection return void.  The number of documents inserted is either one for insertOne, or n for insertMany, where n equals the number of documents passed to insertMany.  There is no need for these methods to return n, since it&apos;s value is implied by the method name and/or their arguments.&lt;/p&gt;</comment>
                            <comment id="786938" author="jeff.yemin" created="Tue, 16 Dec 2014 13:50:14 +0000"  >&lt;p&gt;Only by using the bulk write support introduced in 2.12.0.  See &lt;a href=&quot;http://api.mongodb.org/java/current/com/mongodb/BulkWriteOperation.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://api.mongodb.org/java/current/com/mongodb/BulkWriteOperation.html&lt;/a&gt; for details.&lt;/p&gt;</comment>
                            <comment id="786934" author="thale013" created="Tue, 16 Dec 2014 13:41:14 +0000"  >&lt;p&gt;Is there any other way to retrieve the number of documents that were successfully inserted?&lt;/p&gt;</comment>
                            <comment id="653224" author="sjkyspa" created="Wed, 9 Jul 2014 16:18:44 +0000"  >&lt;p&gt;getUpsertedId()&lt;br/&gt;
Gets the _id value of an upserted document that resulted from this write.&lt;br/&gt;
this is from the official document, but it seems that the upserted id is null, this will cause null exception. Is this by design?&lt;/p&gt;</comment>
                            <comment id="615561" author="jeff.yemin" created="Tue, 10 Jun 2014 15:14:55 +0000"  >&lt;p&gt;It&apos;s by design.  The getlasterror command has always return n : 0 for inserts, and the driver is just mirroring that response.  &apos;n&apos; in this case represents the number of documents matched by the query (for update and remove), and there is no query for insert, so it&apos;s always 0.&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|hrzkrj:</customfieldvalue>

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