Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NoSQL|Mongo : How to use ObjectID ?
NoSQL|Mongo : How to use ObjectID ? [message #1411128] Fri, 22 August 2014 13:10
Tugdual Grall is currently offline Tugdual GrallFriend
Messages: 1
Registered: July 2009
Junior Member
I am not sure to understand correctly the way the ID is generated by EclipseLink.

The default BSON type - stored by MongoDB- for is an ObjectID that is automatically generated by the Java driver and store as a 12bytes in the db.

When I ask my entity to generate the ID for example

 @Id 
 @GeneratedValue()
 @Field(name="_id")
 private String id;


It looks like EclipseLink is using the ID generated by MongoDB Driver but does not store it with the correct format. It is store as a simple string.

For example, with these annotation in the shell, the id looks like:

{ "_id" : "53F740283004D7B7A21DB58E", ...



When generated properly, in the shell it should look like:
{ "_id" : ObjectId("53f73a66300403c9041fda83"), ...



Do I have any way to generate the proper Object ID for MongoDB? (I understand that you can use anything, but I would like to have my Eclipselink application to behave the same way than other FWK)

Also when I have an existing database with some document generate by another application with the proper format, I have no idea how to query -in JQL- it by ID. (since the ID is not a string but an ObjectID). For example in the shell I would use:

db.order.find( { "_id" : ObjectId("53f73a66300403c9041fda83") }  );



So, globally my question is how do we work with ObjectId in EclipseLink?

Previous Topic:DescriptorEventAdapter and Invoice Header/Line
Next Topic:EclipseLink 2.5.2 is returning empty vector with size 1 with getResultList
Goto Forum:
  


Current Time: Tue Jun 30 12:55:14 GMT 2015

Powered by FUDForum. Page generated in 0.02347 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software