I\'m just getting started with MongoDb and I\'ve noticed that I get a lot of duplicate records for entries that I meant to be unique. I would like to know how to use a compo
You can create Unique Indexes on the fields of the document that you'd want to test uniqueness on. They can be composite as well (called compound key indexes in MongoDB land), as you can see from the documentation. Morphia does have a @Indexed annotation to support indexing at the field level. In addition with morphia you can define compound keys at the class level with the @Indexed annotation.