账户实体
public class Account
{
@MongoObjectId
private String _id;
private String name;
public String get_id() {
return _id;
}
public void set_id(String _id) {
this._id = _id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class JongoExample {<br>
MongoClient mongoClient = new MongoClient(); // code to connect with database
DB db = mongoClient.getDB("kommboxj");
Jongo jongo = new Jongo(db);<br>
MongoCollection accountCollection = jongo.getCollection("account");
Account account = new Account();<br>
account.setName("rks");<br>
String accountIdMongo = (String) accountCollection.insert(account).getUpsertedId();}
这里发现acountIdMongo为null,不知道怎么获取,这里要插入账号ObjectId。