Wednesday 15 August 2012

java - Mongojack possible to persist id as string -



java - Mongojack possible to persist id as string -

is possible store id field of type string in pojo string in mongo collection?

i've tried annotate pojo described in official documentation, _id collection property persisted objectid.

here's simple pojo

public class sticker { @id @jsonproperty("_id") private string id; private string name; public string getid() { homecoming id; } public void setid( string id ) { this.id = id; } public string getname() { homecoming name; } public void setname( string name) { this.name= name; } }

it depends whether set id before storing instance in database or not.

if set arbitrary string, string in database. if don't set it, objectid in database, because mongo db creates id you.

java mongodb mongojack

No comments:

Post a Comment