[JAVA-1858] Clarify deprecation of DB in 3.x Created: 11/Jun/15  Updated: 07/Oct/15  Resolved: 04/Sep/15

Status: Closed
Project: Java Driver
Component/s: API, Documentation
Affects Version/s: None
Fix Version/s: 3.1.0

Type: Improvement Priority: Major - P3
Reporter: Ben McCann Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I'm quite confused as to whether DB is deprecated in favor of MongoDatabase. I see that Mongo.getDB is deprecated, but DB itself is not. It's quite confusing and duplicative to have both DB and a MongoDatabase. I think the answer is that one of them is deprecated. However, it hasn't been deprecated in the code and in fact my entire code base compiles fine without a single deprecation warning.



 Comments   
Comment by Jeffrey Yemin [ 07/Oct/15 ]

Released in 3.1.0

Comment by Githook User [ 04/Sep/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1858: Clarified effective deprecation of DB, DBCollection, and DBCursor.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/487c04fd446932be07dfbf23cc37d54e14dc90fd

Comment by Ross Lawley [ 12/Jun/15 ]

Re opening to track the clarifications for when DB will be deprecated.

Comment by Ben McCann [ 11/Jun/15 ]

The reason I filed this is that I don't get a single deprecation warning anywhere in my entire codebase, which is not what you want users to experience when DB goes away one day. However, understanding the situation better now, I see now that's rather unique to me as an author of a client library. I still think we can do better with documenting this though to make it clearer. I sent a PR here: https://github.com/mongodb/mongo-java-driver/pull/318

Comment by Ross Lawley [ 11/Jun/15 ]

Hi chengas123,

You're correct that by deprecating Mongo.getDB we have effectively deprecated DB and DBCollection. Rather, than marking all areas under that code path as deprecated and causing users pain with the 3.x series of the Java Driver we opted to just deprecate the start point. As such DB and DBCollection can now be seen as the legacy API, it will still be accessible for the duration of 3.x series but will eventually be removed.

In the 3.0 driver we introduced MongoDatabase and MongoCollection and these along with the new Document class are favoured over the legacy 2.x classes. This way users can migrate legacy applications to the new API rather than be forced to pick either a 2.x or 3.x driver, this is crucial because the 3.x branch will support the new and upcoming MongoDB features!

Hope that answers your questions, for future reference these style questions are better suited for the mailing list as the JAVA project is specifically for driver based bugs or issues.

As this was a clear design goal for the 3.0 driver I'm closing this ticket as "Works as Designed".

Ross

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