Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7854

Annotation value cannot be concatenated constant

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.6
    • Fix Version/s: 3.0.0-alpha-4, 2.5.4
    • Labels:
      None
    • Environment:
      - OS X
      - Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      - IntelliJ Idea 14 CE \w Groovy plugin
      - Gradle 2.2

      Description

      Following code as .java class works ok:

      UserDAO.java
      public abstract class UserDAO {
          public static final String Select_User_join_Addresses_Features_Images =
              "select "+
              "u.*, a.*, f.*, i.* "+
              "from users u "+
              "left outer join addresses a on (u.id = a.user_id) "+
              "left outer join userfeatures f on (u.id = f.user_id) "+
              "left outer join images i on (u.id = i.user_id) ";
      
          public static final String Select_User_by_id =
                  Select_User_join_Addresses_Features_Images + "where u.id = :id";
      
          public static final String Select_User_by_email =
                  Select_User_join_Addresses_Features_Images + "where u.email = lower(:email)";
      
          @SqlQuery(Select_User_by_id)
          abstract FoldingList<User> findById(@Bind("id") long id);
      }
      

      However if I write and compile it as Groovy, I get "Expected 'UserDAO.Select_User_by_id' to be an inline constant of type java.lang.String not a property expression" error from compiler.

      Also if works if those constant String are in separate .java class that is accessed from annotation (within a .groovy class), but not if they are in separate .groovy file.

      So the difference seems to be that constant strings are not concatenated at compile-time in Groovy, but in Java they are? Is this by design or is it a bug that can be fixed?

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              situokko Simo Tuokko
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: