Storing _id as String

21 views
Skip to first unread message

prit kalra

unread,
Nov 27, 2018, 5:59:47 AM11/27/18
to Morphia
Hi,

I am new to morphia I have a situation where I want to replace an existing document  with a new document or create a new document. save() method allows me to do the same but I need to provide _id field. I want to know if I can store _id as String field in morphia 1.3.2 as currently I'm not specifying anything as my _id and it is automatically created.
I have two primary key indexes which are string, I am thinking if somehow I can create the _id field as a combination of these two strings which will be unique throughout.
Also if I proceed to do the same, what happens if later I append another string field to create my new _id field. Do I have to delete and re-create new _ids altogether.


My issue is that when updating I want to replace the entire, I have a method :


<T> UpdateResults updateFirst(Query<T> query, T entity, boolean createIfMissing);

which does the same but it only works for non versioned entities.

Any Suggestions ?




Reply all
Reply to author
Forward
0 new messages