[JAVA-3124] Could Not Update Object When One Unique Key is NULL Created: 18/Dec/18  Updated: 11/Sep/19  Resolved: 11/Jan/19

Status: Closed
Project: Java Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Ritesh Kumar Singh Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Could Not Update Object When One Unique Key is NULL.

When i am integrating MongoDB with my java Aplication and MAP of java support NULL as unique key then why i am unable to save my Object.

 

NOTE: Null key can be a business senario for some organisation

To collect leftover data.

 

Try to run below main program in java

public static void main(String[] args)
{
       Map<String, String> strMap= new HashMap<>();
        strMap.put(null,"Hello World");
        System.out.print(strMap);
}

   



 Comments   
Comment by Jeffrey Yemin [ 18/Dec/18 ]

Hi ritesh.singh

As with JSON, MongoDB's BSON format (see the e_name production) does not support null keys. It does, however, support empty keys, so you can use the empty string for any leftover data.

Since null keys would require a major change to the BSON format, it's doubtful that MongoDB will ever support them.

Generated at Thu Feb 08 08:58:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.