Issue 210 in morphia: Add options to just store _id for refs

1 view
Skip to first unread message

mor...@googlecode.com

unread,
Jan 9, 2011, 6:31:35 PM1/9/11
to morphia...@googlegroups.com
Status: Accepted
Owner: scotthernandez
Labels: Type-Enhancement Priority-Low Milestone-Release1.2

New issue 210 by scotthernandez: Add options to just store _id for refs
http://code.google.com/p/morphia/issues/detail?id=210

Add/support an annotation to allow just use the _id value instead of a
DBRef; this will allow us to support migrating/integrating with other
frameworks.

For now you can use @preLoad/postPersist to do this with custom code per
field.

mor...@googlecode.com

unread,
Jun 16, 2011, 12:54:53 PM6/16/11
to morphia...@googlegroups.com

Comment #1 on issue 210 by n...@transmachina.com: Add options to just store

So I would need to mark the field as @Transient so that Morphia doesn't try
to handle it automatically?

mor...@googlecode.com

unread,
Jun 16, 2011, 1:38:11 PM6/16/11
to morphia...@googlegroups.com

Comment #2 on issue 210 by scotthernandez: Add options to just store _id
for refs
http://code.google.com/p/morphia/issues/detail?id=210

n...@transmachina.com: Can you ask your question on the list? I don't
understand what you mean. You can mark it as @Transient and it will be
ignored by morphia, yes; I'm not sure how that applies to this issue.

mor...@googlecode.com

unread,
Jun 16, 2011, 1:46:15 PM6/16/11
to morphia...@googlegroups.com

Comment #3 on issue 210 by n...@transmachina.com: Add options to just store

I don't understand how I would use @preLoad/postPersist to work around this
issue. If I currently have a field:

@Reference
MyClass ref;

how do I store this simply as an ObjectId and not the full DBRef with $id
and $ref? And even if I implement a workaround, does that mean that I will
no longer we able to query on this field?

Nicholas Cottrell
Transmachina Language Technologies Website translation technology
http://www.transmachina.com/ Multilingual software development
Stockholm, Sweden Web communication consultants

Email: n...@transmachina.com
Skype: niccottrell
Ph. +46 70 885 9690

mor...@googlecode.com

unread,
Dec 25, 2011, 1:02:24 PM12/25/11
to morphia...@googlegroups.com

Comment #4 on issue 210 by scotthernandez: Add options to just store _id
for refs
http://code.google.com/p/morphia/issues/detail?id=210

Issue 311 has been merged into this issue.

mor...@googlecode.com

unread,
Mar 1, 2012, 7:22:28 AM3/1/12
to morphia...@googlegroups.com

Comment #5 on issue 210 by scotthernandez: Add options to just store _id
for refs
http://code.google.com/p/morphia/issues/detail?id=210

You would convert the stored DBRef in prePersist to just have the _id
field, and then in preLoad you would reverse this. To query you will have
to just send the _id value and disable validation since you are bypassing
the default behavior.

Reply all
Reply to author
Forward
0 new messages