Community
Participate
Working Groups
There is a question from Tugdual Grall about MongoDB and EclipseLink on the forum but there is no responses. Tugdual Grall works at MongoDB. https://www.eclipse.org/forums/index.php/t/801853/ I'm interested by the answer. So I ask here if anybody can answer. Thank you.
I recently picked up EclipseLink NoSQL plugin development and I used the MongoDB implementation to learn the basics. So here is the way it generates the ID: public class OIDSequence extends Sequence { @Override public Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName) { return new ObjectId().toByteArray(); } ... } If this is still important I could try to remove the toByteArray() call and see what happens.
Another solution might lie in MongoInteraction.buildDBObject It looks doable to check if it is an ID field and convert the objectID byte array back to an ObjectID public DBObject buildDBObject(MongoRecord record) { DBObject object = new BasicDBObject(); for (Iterator iterator = record.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry entry = (Map.Entry)iterator.next(); if (entry.getValue() instanceof MongoRecord) { object.put((String)entry.getKey(), buildDBObject((MongoRecord)entry.getValue())); } else { object.put((String)entry.getKey(), entry.getValue()); } } return object; }
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink