<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:29 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-85] CompareTo of ObjectId java driver returns different value than MongoDB implementation </title>
                <link>https://jira.mongodb.org/browse/JAVA-85</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I&apos;am sorting messages in my program according to the ObjectId and than trying to fetch messages from MongoDB with ID bigger than the one I have, but than I&apos;m getting messages I already have.&lt;br/&gt;
After some tests and reading the documentation it looks like the Java ObjectId / compareTo is wrong.&lt;br/&gt;
My test:&lt;br/&gt;
    @Test&lt;br/&gt;
    public void compareMongoToMongo2() &lt;/p&gt;
{
        final String MONGO_ID_1 = &quot;4b5d4825f5f32ad607e4c7c7&quot;;
        final String MONGO_ID_2 = &quot;4b5d4825f5f32ad6eae3c7c7&quot;;
        ObjectId id1 = new ObjectId(MONGO_ID_1);
        ObjectId id2 = new ObjectId(MONGO_ID_2);
        System.out.println(id1.compareTo(id2));
    }
&lt;p&gt;output: 29&lt;br/&gt;
Meaning MONGO_ID_1 &amp;gt; MONGO_ID_2  &lt;/p&gt;

&lt;p&gt;But when running the following query on MongoDB:&lt;br/&gt;
&amp;gt; db.messages.find({&quot;_id&quot;: {$gt: ObjectId(&quot;4b5d4825f5f32ad607e4c7c7&quot;)}} , &lt;/p&gt;
{&quot;_id&quot;:1}
&lt;p&gt; )&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4b5d4825f5f32ad6eae3c7c7&quot;) }
&lt;p&gt;Meaning MONGO_ID_2 &amp;gt; MONGO_ID_1&lt;/p&gt;</description>
                <environment>Linux, Jboss</environment>
        <key id="11227">JAVA-85</key>
            <summary>CompareTo of ObjectId java driver returns different value than MongoDB implementation </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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="dlevison">Dan Levison</reporter>
                        <labels>
                    </labels>
                <created>Mon, 1 Feb 2010 10:32:35 +0000</created>
                <updated>Wed, 14 May 2014 19:04:43 +0000</updated>
                            <resolved>Sun, 30 Jan 2011 07:08:09 +0000</resolved>
                                                    <fixVersion>2.5</fixVersion>
                                                        <votes>3</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="25185" author="auto" created="Thu, 3 Mar 2011 22:19:44 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-85&quot; title=&quot;CompareTo of ObjectId java driver returns different value than MongoDB implementation &quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-85&quot;&gt;&lt;del&gt;JAVA-85&lt;/del&gt;&lt;/a&gt;: removed trick to compare inc wrap&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/170127bdb63e9c7b4dded9f3add7d670935d53cd&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/170127bdb63e9c7b4dded9f3add7d670935d53cd&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="25171" author="auto" created="Thu, 3 Mar 2011 20:31:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-85&quot; title=&quot;CompareTo of ObjectId java driver returns different value than MongoDB implementation &quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-85&quot;&gt;&lt;del&gt;JAVA-85&lt;/del&gt;&lt;/a&gt;: refactoring of ObjectId, to store values native, and encode/decode big endian. Fixes some flaws with Increment value failing comparison.&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/b7d9986e5ac45370e77797d922bb844cf8e05ffb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/b7d9986e5ac45370e77797d922bb844cf8e05ffb&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="22823" author="auto" created="Sun, 30 Jan 2011 07:08:17 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;erh&apos;, u&apos;name&apos;: u&apos;Eliot Horowitz&apos;, u&apos;email&apos;: u&apos;eliot@10gen.com&apos;}
&lt;p&gt;Message: fix ObjectId.compareTo &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-85&quot; title=&quot;CompareTo of ObjectId java driver returns different value than MongoDB implementation &quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-85&quot;&gt;&lt;del&gt;JAVA-85&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/04aa553e59dc1b1961198ed9235573653dff8aef&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/04aa553e59dc1b1961198ed9235573653dff8aef&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <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|hrgio7:</customfieldvalue>

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