Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nitriteMapper is null? #808

Closed
yonimoses opened this issue Apr 25, 2023 · 1 comment
Closed

nitriteMapper is null? #808

yonimoses opened this issue Apr 25, 2023 · 1 comment

Comments

@yonimoses
Copy link

Hi,

Trying to work with nitrite 3.X, so far so good.
I'm mainly using the ObjectRepository, but I wanted to try querying nested docs using the getCollection and got the

NitriteMapper.isValueType(Object)" because "nitriteMapper" is null in
ValidationUtils.validateSearchTerm

My actual code that causes that is :
nitrite.getCollection(Advisory.class.getName()).find(eq("advisory_details.summary", "Text To Match"))

any suggestions?

@anidotnet
Copy link
Contributor

You need to use ObjectRepository api instead of collection.

Try to use:

ObjectRepository<Advisory> repository = nitrite.getRepository(Advisory.class);
Cursor<Advisory> cursor = repository.find(eq("advisory_details.summary", "Text To Match"));

NitriteMapper is used in ObjectRepository to map object to document and vice versa. In NitriteCollection, for obvious reason NitriteMapper is not set as it does not deal with objects directly. So mix and match of api is not advisable. If you are dealing with objects, you need to use ObjectRepository api, if you are dealing with only documents, use collection api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants