我使用 BasicDBObject 将哈希表存储在 mongodb 中。现在我想检索这个哈希表。我该怎么做?
HashTable<String, Login> loginHashTable;
HashTable<String, Other> otherHashTable;
DBCollection coll = db.getCollection(users);
BasicDBObject obj = new BasicDBObject();
obj.insert("HashTable1", loginHashTable);
obj.insert("HashTable2", otherHashTable);
coll.insert(obj);
它正确存储而没有错误,但我如何检索一个特定的哈希表。假设我想检索 loginHashTable。那么,我该怎么做呢?
Somewhat like this:
HashTable <String,Login> retrieveTable = obj.get("HashTable1");
我的登录类是这样的:
public class Login extends ReflectionDBObject implements Serializable
{
/** Enterprise user name used for authentication. */
public String username = null;
/** Enterprise password used for authentication. */
public String password = null;
/**Name of manufacturer of mobile phone*/
public String manufacturer = null;
/**Name of model of mobile phone*/
public String model = null;
/**Language in which Mobile software release is needed*/
public String language = null;
/**Current version of the software*/
public String version = null;
public static String id;
}
我的另一堂课是这样的:
public class Other extends ReflectionDBObject implements Serializable
{
public String sessionID = null;
}