Results 1 to 4 of 4

Thread: Repository Query Method - NotNull keyword not returning anything

  1. #1
    Join Date
    Apr 2011
    Posts
    7

    Default Repository Query Method - NotNull keyword not returning anything

    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

  2. #2
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    Hi Derek,

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

    Cheers,
    Ollie

  3. #3
    Join Date
    Apr 2011
    Posts
    7

    Default

    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

  4. #4
    Join Date
    Apr 2006
    Location
    Dresden, Germany
    Posts
    483

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •