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, ie http://abc.com/customer-50 , http://abc.com/customer-51 , http://abc.com/customer-52 .
Now it become http://abc.com/customer-4d1b4687a6d5437619000000
I will need to change all the reference classes from long to objectId.
Is it possible to keep the original design (which uses Long id, instead of ObjectId)?
Thanks!
请查看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 (链接更新) https://github.com/MorphiaOrg/morphia/blob/master/ morphia / src / test / java / xyz / morphia / utils / LongIdEntity.java (再次更新)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.