Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink and MongoDB - Auto incrementing field
EclipseLink and MongoDB - Auto incrementing field [message #1063780] Fri, 14 June 2013 08:21 Go to next message
Michael Hunziker is currently offline Michael HunzikerFriend
Messages: 4
Registered: June 2013
Junior Member
Dear all!

We're using Eclipse Link 2.4 with MongoDB.

Due to a business requirement we need to be able to generate an auto incrementing sequence (as documented here: docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field)

Has anyone ever had to do this? The problem is that the ObjectID's are not really human readable. E.g. in URLs: htt...://bookStore.com/books/51BAB665040EE9317CAD525A.
Our customer would like to be able to use an ID like 1234 to identify a book...

What do you think about this?
Is there a possibility to implement the solution proposed by MongoDB above with EclipseLink/NOSQL? Currently I don't see how I could call the mongodb-function "getNextSequence"...

Thank you for your help!

Cheers
Michael

Re: EclipseLink and MongoDB - Auto incrementing field [message #1064285 is a reply to message #1063780] Tue, 18 June 2013 14:39 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can use a native query to create your id and either assign it to your object yourself, or use a custom Sequence in EclipseLink to use your function to define the id.

Another option would be to map a Sequence entity to a collection and keep a counter field in it that you increment and commit to get a new id (use optimistic locking).


James : Wiki : Book : Blog : Twitter
Re: EclipseLink and MongoDB - Auto incrementing field [message #1064293 is a reply to message #1064285] Tue, 18 June 2013 14:52 Go to previous message
Michael Hunziker is currently offline Michael HunzikerFriend
Messages: 4
Registered: June 2013
Junior Member
Perfect, thank you James!
Previous Topic:SetFirstResult and setMaxResult problem if exist @OneToMany relation
Next Topic:@OneToMany and @ManyToOne in MongoDB and JPA -EISOneToOneMapping cannot be cast to
Goto Forum:
  


Current Time: Sat Apr 20 04:22:06 GMT 2024

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

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

Back to the top