简体   繁体   中英

Can't retrieve extisting document with Morphia 2.0.2

A document is create manually on the database, let's call this collection Employee. I just create a class, with all the correct annotation, and then I try to query the database in order to retrieve my manually inserted Employee. It doesn't work.

Then I create my document using Morphia directly, and I can retrieve it correctly.

I saw an _t property on the document, and on all its embedded class.

I've tried adding that property to my document and everything works fine.

The problem is that I have a huge database with existing documents: what am I supposed to do? add those properties to all documents and al "embedded" ones?

If you create the document manually, you must include the discriminator and discriminatorKey in that document. If you have your entity configured to used the discriminator (which is on by default), Morphia won't find those documents because the query will look for that discriminator as part of the query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM