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.
So I would need to mark the field as @Transient so that Morphia doesn't try
to handle it automatically?
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.
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
Issue 311 has been merged into this issue.
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.