Results 1 to 3 of 3

Thread: Getting errors using constants in @RelatedTo etc. Using Groovy

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

    Default 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. #2
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

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

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

    Default

    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

Posting Permissions

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