jg15617651654
流年你奈我何
采纳率0%
2017-04-28 06:46 阅读 1.9k

怎样将mongodb 在java中对应的方法,转换成SQL的

如下例所示: 现在还数据库了(postgreSQL),我该把这些方法转换成相对应的什么方法? 求解答
protected DBObject createWaveletDBQuery() {
DBObject query = new BasicDBObject();
query.put(MongoDbDeltaStoreUtil.FIELD_WAVE_ID, waveletName.waveId.serialise());
query.put(MongoDbDeltaStoreUtil.FIELD_WAVELET_ID, waveletName.waveletId.serialise());
return query;
}

public WaveletDeltaRecord getDelta(long version) throws IOException {

DBObject query = createWaveletDBQuery();
query.put(MongoDbDeltaStoreUtil.FIELD_TRANSFORMED_APPLIEDATVERSION, version);

DBObject result = deltaDbCollection.findOne(query);

WaveletDeltaRecord waveletDelta = null;

if (result != null) try {
  waveletDelta = MongoDbDeltaStoreUtil.deserializeWaveletDeltaRecord(result);
} catch (PersistenceException e) {
  throw new IOException(e);
}
return waveletDelta;

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • devmiao devmiao 2017-04-28 07:20
    点赞 1 评论 复制链接分享
  • jg15617651654 流年你奈我何 2017-04-28 07:28

    protected JSONObject createWaveletDBQuery() {
    JSONObject query = new JSONObject();
    try {
    query.put(PostgresDeltaUtil.FIELD_WAVE_ID, waveletName.waveId.serialise());
    query.put(PostgresDeltaUtil.FIELD_WAVELET_ID, waveletName.waveletId.serialise());
    } catch (JSONException e) {
    e.printStackTrace();
    }
    return query;
    }
    我直接把它转换成JSONObject 格式,但是mongodb 中的findone方法我要怎么代替

    点赞 评论 复制链接分享

相关推荐