Bug 443858 - Question about EclipseLink and MongoDB on the forum but no answer
Summary: Question about EclipseLink and MongoDB on the forum but no answer
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: mongodb
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-11 12:50 EDT by Gautier de SAINT MARTIN LACAZE CLA
Modified: 2022-06-09 10:04 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gautier de SAINT MARTIN LACAZE CLA 2014-09-11 12:50:55 EDT
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.
Comment 1 Ray Hulha CLA 2015-10-01 06:27:49 EDT
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.
Comment 2 Ray Hulha CLA 2015-10-01 07:39:48 EDT
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;
    }
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:04:02 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink