title: Using not hard coded values in query, jpa repository and spring boot
body: <p>I'm using a query in my spring boot project with hard coded values and that is fine: </p>
  
  <pre><code>    @Query("select user from Users user where user.mobileNumber=?1 and not user.status=-2")
  Users FindNotDeletedUserByMobileNumber(String MobileNumber);
  </code></pre>
  
  <p>But, I wanted to use not hardcoded values, eg. reading from an enum, I tried this : </p>
  
  <pre><code>    @Query("select user from Users user where user.mobileNumber=?1 and not user.status=com.taxikar.enums.User_Status.Deleted")
  Users FindNotDeletedUserByMobileNumber(String MobileNumber)
  </code></pre>
  
  <p>But this one gives error while building : </p>
  
  <pre><code>'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.taxikar.entity.Users com.taxikar.repository.UserRepository.FindNotDeletedUserByMobileNumber(java.lang.String)!
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
  </code></pre>
  
  <p>I use this enum values in my other classes and they are working fine, for example:</p>
  
  <pre><code>if (user.getStatus() == User_Status.Deleted.getId())
              return new BaseResponse(BR_Status.error.getId(), BR_ErrorCodes.NotAuthorizedUser.getStringValue() + "01",
                      "error 755", user.getId());
  </code></pre>
  
  <p>Even using <code>.getId</code> or <code>.getStringValue</code> like the one above but at end of my query doesn't solve anything. What am I doing wrong ?</p>
  
  <p>Here is my enums code : </p>
  
  <pre><code>    public enum User_Status implements IResponse
  {
      Deleted(-2),
      Unauthorized(-1),
      NotCompleteGeneralInfo(0),
      CompleteGeneralInfo(1);
  
      private int value;
      private String stringValue;
  
      User_Status(int value)
      {
          this.value = value;
      }
      User_Status(String stringValue){this.stringValue=stringValue;}
      @Override
      public int getId()
      {
          return value;
      }
  
      @Override
      public String getStringValue()
      {
          return stringValue;
      }
  }
  </code></pre>
  
  <p>This enum implements <code>IResponse</code> which is like this : </p>
  
  <pre><code>public interface IResponse
  {
      String getStringValue();
  
      int getId();
  }
  </code></pre>
  
  <p>Here Is my repository : </p>
  
  <pre><code>public interface UserRepository extends JpaRepository&lt;Users, String&gt;
  {
      @Query("select user from Users user where user.mobileNumber=?1 and not user.status=com.taxikar.enums.User_Status.Deleted")
      Users FindNotDeletedUserByMobileNumber(String MobileNumber);
  }
  </code></pre>
  
  <p>And here is my entity class :</p>
  
  <pre><code>    @Entity
  @Table(name = "users")
  public class Users
  {
      // these fields are feed by us not the user
      @Id
      @GeneratedValue(generator = "uuid2")
      @Column(columnDefinition = "char(36)")
      @GenericGenerator(name = "uuid2", strategy = "uuid2")
      private String id;
      @Column(name = "STATUS") // User status ===&gt;-2: Deleted , -1: unauthorized  , 0: user info is not complete ,  1: complete user
      private int status;
      @Column(name = "RATE")
      private String rate;
  
      //Not Optional fields
      @Column(name = "FIRST_NAME")
      private String firstName;
      @Column(name = "LAST_NAME")
      private String lastName;
      @Column(name = "SEX") // Sex ====&gt; 1:women 2:men
      private int sex;
      @Column(name = "MOBILE_NUMBER")
      private String mobileNumber;
      @Column(name = "USER_IMG")
      private String userImg;
      @Column(name = "IDENTITY_NUMBER")
      private String identityNumber;
      @Column(name = "USER_IDENTITY_CARD_IMG")
      private String userIdentityCardImg;
  
  
      //Optional fields
      @Column(name = "EMAIL")
      private String email;
      @Column(name = "BIRTHDAY")
      private String birthday;
      @Column(name = "DESCRIPTION")
      private String description;
  
      // not Optional fields for driver
      @OneToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "DRIVER_DETAIL")
      private DriverDetail driverDetail;
  
      //Login related fields
      @Column(name = "TOKEN")
      private String token;
      @Column(name = "TOKEN_TIMESTAMP")
      private Timestamp tokenTimeStamp;
      @Column(name="SMS_COUNT")
      private int smsCount;
      @Column(name="SMS_COUNT_TIMESTAMP")
      private Timestamp smsCountTimeStamp;
  
      +++ constructor and setters and getters. 
  
      }
  </code></pre>