Results 1 to 7 of 7

Thread: Using Enum in Derived Query Repo not working.

  1. #1
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default Using Enum in Derived Query Repo not working.

    Here is my enum

    Code:
    public enum EventVisibility {
        PUBLIC,
        PUBLIC_INVITE_ONLY,
        SEMI_PRIVATE,
        PRIVATE
    }
    It is used for a visibility property of my Event domain object.

    private EventVisibility visibility = EventVisibility.PUBLIC;

    I am able to save Events and it saves the Visibility, but when I try to use it in a derived repo query, it doesn't work. Anything I am missing here.

    This is my interface method of my EventRepository

    public Page<Event> findByVisibility(EventVisibility visibility, Pageable page);

    I would think it would work automatically.

    Thanks Mark

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

    Default

    Wht store are you working with? What does "not working" actually mean? Exception?

  3. #3
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    I wasn't seeing an exception logged, but stepping through the code it looks like it was expecting my enum to be a Node or a Relationship, when it is not.

    type="EventVisibility" and this is what it was about to throw.

    InvalidEntityTypeException("Type " + type + " is neither a @NodeEntity nor a @RelationshipEntity");

    maybe the name of the interface method is incorrect, I thought if you did findBy{variable name} would do the trick of returning.

    Thanks

    Mark

  4. #4
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    It should just work and this looks like a bug. "Just works" means it should return data and not throw an exception.

    Thanks

    Mark

  5. #5
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Last edited by MichaelHunger; Feb 7th, 2012 at 08:52 AM.

  6. #6
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    I looked into it, it would need to apply the same conversions to non-basic query parameters as it would do on properties. Right now to work around this could you pass in Enum.name() (aka a String or another primitive value) to the derived finder method?

    Thanks a lot

    Michael

  7. #7
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    Yes, I was thinking I could do that workaround till the next release with the fix.

    Thanks for looking into it.

    Mark

Posting Permissions

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