Java - Saving Objects Using DBObject
The Java driver provides a DBObject interface to save custom objects to the database. For example, suppose one had a class called Tweet that they wanted to save:
Then you can say:
When a document is retrieved from the database, it is automatically converted to a DBObject. To convert it to an instance of your class, use DBCollection.setObjectClass():
If for some reason you wanted to change the message you can simply take that tweet and save it back after updating the field.
|