Simple solution but I think it is Orthodox way.
- Put an element into the ReturnMap. e.g.
map.put("_id", map.get("service_id"));
Now, I can prevent duplication of values.
If there is better way, I will choose that one as an answer :D Thanks
Question
I am working with MongoDB and Spring 3.2.8.
What I have to do is query to Oracle database with MyBatis and put the ResultMap which returns from the query into Mongo DB.
Situations.
ResultMap works quite well as I expected. It returns proper HashMap<String, Object>
or List<HashMap<String, Object>
In that ResultMap, I have an element named 'service_id' which should replace '_id' in mongo.
Push into mongoDB with MongoTemplate(org.springframework.data.mongo.core) works also well.
The problem is since mongoDB uses its own '_id' as a primary key, if I put same object it sizes double.
Question.
Condition.
Part of Source code. tmp.insert(map, collectionName); this tmp is MongoTemplate and I assume that it does not have any method to control '_id'.
Thank you :D
La solution
Simple solution but I think it is Orthodox way.
map.put("_id", map.get("service_id"));
Now, I can prevent duplication of values.
If there is better way, I will choose that one as an answer :D Thanks