Announcement Announcement Module
Collapse
No announcement yet.
Getting errors using constants in @RelatedTo etc. Using Groovy Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting errors using constants in @RelatedTo etc. Using Groovy

    So in a class I have some constants

    public static Final String A_CONSTANT="hello"

    I am using this constant in my mapping

    But I get these errors

    Groovyc: expected 'FAVORITE_TABLES' to be an inline constant of type java.lang.String not a field expression in @org.springframework.data.neo4j.annotation.Related To
    Groovyc: Attribute 'type' should have type 'java.lang.String'; but found type 'java.lang.Object' in @org.springframework.data.neo4j.annotation.Related To
    Groovyc: expected 'FAVORITE_VIDEOS' to be an inline constant of type java.lang.String not a field expression in @org.springframework.data.neo4j.annotation.Related To

    Partial of my Account entity code

    Code:
    @Entity
    @NodeEntity(partial = true)
    class Account implements UserDetails {
    
      public static final String FAVORITE_TABLES = "FAVORITE_TABLES"
      public static final String FAVORITE_VIDEOS = "FAVORITE_VIDEOS"
    As you can see they are constants.

    The big difference that might cause this is that my classes are all written with Groovy. So I think that makes it not work. Is there some way to fix this, or do I have to convert all my domain objects to Java instead of Groovy

    Thanks

    Mark

  • #2
    Hmm that is more a Groovy/Java interop question? Does casting them to a string help?

    Comment


    • #3
      Odd, I thought I replied to this thread with the solution.

      Basically, to access them as constants I had to prefix it with the class name regardless of if I used them inside the same class they were declared.

      So I had to use Account.FAVORITE_TABLES

      Mark

      Comment

      Working...
      X