Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:12:19+00:00 2026-05-27T05:12:19+00:00

Background: My REST service project was started up by using Hibernate. I use id

  • 0

Background:

My REST service project was started up by using Hibernate. I use id (Long) in domain class as part of the identifier in rest url, for example:

http://abc.com/customer-50, where 50 is the Long id.

The Hibernate Annotated class is as below:

public class Customer {
@Id
@GeneratedValue
private Long id;
}

Now I need to migrate our design to Mongodb. The natural choice is using Morphia, which is an entity framework.

Problem:
In Morphia, the id field is ObjectId

@Id private ObjectId id;

This will cause problem because:
1. It is not auto-increment, i.e. http://abc.com/customer-50, http://abc.com/customer-51, http://abc.com/customer-52.

Now it become http://abc.com/customer-4d1b4687a6d5437619000000

  1. I will need to change all the reference classes from long to objectId.

  2. Is it possible to keep the original design (which uses Long id, instead of ObjectId)?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:12:19+00:00Added an answer on May 27, 2026 at 5:12 am

    Take a look at https://code.google.com/p/morphia/source/browse/trunk/morphia/src/main/java/com/google/code/morphia/utils/LongIdEntity.java https://github.com/mongodb/morphia/blob/master/morphia/src/test/java/org/mongodb/morphia/utils/LongIdEntity.java (link updated)
    https://github.com/MorphiaOrg/morphia/blob/master/morphia/src/test/java/xyz/morphia/utils/LongIdEntity.java (updated again)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a REST web service class which i call HttpRequest using curl.I wrote
First a little bit of background: I have a REST service in WCF 4
Background: I have a Visual Studio solution consisting of a website + REST web-service
Some background I am planning to writing a REST service which helps facilitate collaboration
The background I'm developing a REST API for a C#.NET web application using WCF.
I'm currently kicking off a background thread to do some REST queries in my
Goal Java client for Yahoo's HotJobs Resumé Search REST API . Background I'm used
Background: At my company we are developing a bunch applications that are using the
Background I am writing and using a very simple CGI-based (Perl) content management tool
I started a new job in a company that loves using the word, enterprise.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.