title: Syntax error parsing JPQL: An identification variable must be provided for a range variable declaration
body: <p>When trying to run this code: </p>
  
  <pre><code>List&lt;Users&gt; list = em.createQuery("select balance b from Users where b.userName = '" + user_name.getText() +"'", Users.class).getResultList();
  </code></pre>
  
  <p>I encounter this error message: </p>
  
  <blockquote>
    <p>Syntax error parsing [select balance b from Users where b.userName = 'a']. 
    [28, 28] An identification variable must be provided for a range variable declaration.</p>
  </blockquote>
  
  <p>I want to retrieve the Integer balance from the User whose name is typed in the user_name TextField.
  I am quite a beginner on this topic and the internet gives complicated info. Can someone please kindly explain what is wrong ?</p>
  
  <p>Part of the Users class</p>
  
  <pre><code>@Entity
  @Table(name = "users")
  @XmlRootElement
  @NamedQueries({
  @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
  @NamedQuery(name = "Users.findByUserName", query = "SELECT u FROM Users u WHERE u.userName = :userName"),
  @NamedQuery(name = "Users.findByBalance", query = "SELECT u FROM Users u WHERE u.balance = :balance"),
  @NamedQuery(name = "Users.findByFirstName", query = "SELECT u FROM Users u WHERE u.firstName = :firstName"),
  @NamedQuery(name = "Users.findByLastName", query = "SELECT u FROM Users u WHERE u.lastName = :lastName"),
  @NamedQuery(name = "Users.findByIban", query = "SELECT u FROM Users u WHERE u.iban = :iban"),
  @NamedQuery(name = "Users.findByCharacterSlots", query = "SELECT u     FROM     Users u WHERE u.characterSlots = :characterSlots"),
  @NamedQuery(name = "Users.findByLastPayment", query = "SELECT u FROM         Users u WHERE u.lastPayment = :lastPayment"),
  @NamedQuery(name = "Users.findByMonthsPayed", query = "SELECT u FROM Users u WHERE u.monthsPayed = :monthsPayed"),
  @NamedQuery(name = "Users.findByPassword", query = "SELECT u FROM Users u WHERE u.password = :password"),
  @NamedQuery(name = "Users.findByBanned", query = "SELECT u FROM Users u WHERE u.banned = :banned")})
  public class Users implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @Basic(optional = false)
  @Column(name = "user_name")
  private String userName;
  @Column(name = "balance")
  private Integer balance;
  @Column(name = "first_name")
  private String firstName;
  @Column(name = "last_name")
  private String lastName;
  @Column(name = "iban")
  private String iban;
  @Column(name = "character_slots")
  private Integer characterSlots;
  @Column(name = "last_payment")
  @Temporal(TemporalType.DATE)
  private Date lastPayment;
  @Column(name = "months_payed")
  private Integer monthsPayed;
  @Column(name = "password")
  private String password;
  @Column(name = "banned")
  private Boolean banned;
  @ManyToMany(mappedBy = "usersCollection")
  private Collection&lt;Servers&gt; serversCollection;
  @ManyToMany(mappedBy = "usersCollection")
  private Collection&lt;Characters&gt; charactersCollection;
  
  public Users() {
  }
  
  public Users(String userName, Integer balance, String firstName,         String     lastName, String iban, Integer characterSlots, Date lastPayment,     Integer monthsPayed, String password, Boolean banned) {
      this.userName = userName;
      this.balance = balance;
      this.firstName = firstName;
      this.lastName = lastName;
      this.iban = iban;
      this.characterSlots = characterSlots;
      this.lastPayment = lastPayment;
      this.monthsPayed = monthsPayed;
      this.password = password;
      this.banned = banned;
  }
  </code></pre>