PDA

View Full Version : Repository Query Method - NotNull keyword not returning anything



DerekHardy
May 1st, 2011, 06:19 AM
Hi

I'm trying to create a repository query method that uses the keyword NotNull, for example

List<Wine> findByWineNameNotNull();

But it's not returning any data, but I know there's matching data and a simple mongodb query to run the following

db.wine.find({"wineName": {"$ne": null}}, {wineName: 1});

works fine and returns the expected results.

Has anybody used the NotNull (or the IsNotNull) keyword and got it to work?

Have I missed something?

Thanks in advance

Derek

Oliver Gierke
May 1st, 2011, 11:54 AM
Hi Derek,

have you tried setting the log level to debug? MongoQueryCreator should log the actual Mongo query created from the method.

Cheers,
Ollie

DerekHardy
May 1st, 2011, 02:10 PM
Hi Ollie

Thanks so much for the quick reply, especially on a sunday.

The output from the MongoQueryCreator was

"Created query { "wineName" : { }}"

And then there was this from the MongoTemplate

"find using query: { "wineName" : { }} fields: null for class: class com.xyz.Wine" }

Where I would've expected to see the {"$ne" : null}

Bug?

Derek

Oliver Gierke
May 2nd, 2011, 02:24 AM
Yes, I think so. It seems MongoQueryCreator doesn't cover the NotNull case at all. Feel fre to raise bug in JIRA.

Thanks for spotting this!
Ollie