Announcement Announcement Module
Collapse
No announcement yet.
Using Enum in Derived Query Repo not working. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Wht store are you working with? What does "not working" actually mean? Exception?

    Comment


    • #3
      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

      Comment


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

        Thanks

        Mark

        Comment


        • #5
          Issue raised: https://jira.springsource.org/browse/DATAGRAPH-193

          Thanks

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

          Comment


          • #6
            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

            Comment


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

              Thanks for looking into it.

              Mark

              Comment

              Working...
              X