title: Hibernate error - QuerySyntaxException: users is not mapped [from users]
body: <p>I'm trying to get a list of all the users from "users" table and I get the following error:</p>
  
  <pre><code>org.hibernate.hql.internal.ast.QuerySyntaxException: users is not mapped [from users]
  org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
  org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
  org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
  </code></pre>
  
  <p>This is the code I wrote to add/get users:</p>
  
  <pre><code>public List&lt;User&gt; getUsers() {
      Session session = HibernateUtil.getSessionFactory().getCurrentSession();
      session.beginTransaction();
      List&lt;User&gt; result = (List&lt;User&gt;) session.createQuery("from users").list();
      session.getTransaction().commit();
      return result;
  }
  
  public void addUser(User user) {
      Session session = HibernateUtil.getSessionFactory().getCurrentSession();
      session.beginTransaction();
      session.save(user);
      session.getTransaction().commit();
  }
  
  public void addUser(List&lt;User&gt; users) {
      Session session = HibernateUtil.getSessionFactory().getCurrentSession();
      session.beginTransaction();
      for (User user : users) {
          session.save(user);
      }
      session.getTransaction().commit();
  }
  </code></pre>
  
  <p>Adding users works, but when I use the getUsers function I get these error.</p>
  
  <p>This is my hibernate config file:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/test&lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;root&lt;/property&gt;
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="hibernate.default_schema"&gt;test&lt;/property&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/property&gt;
  
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;property name="format_sql"&gt;true&lt;/property&gt;
      &lt;property name="hbm2ddl.auto"&gt;create-drop&lt;/property&gt;
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
      &lt;!-- Mapping files will go here.... --&gt;
  
      &lt;mapping class="model.Company" /&gt;
      &lt;mapping class="model.Conference" /&gt;
      &lt;mapping class="model.ConferencesParticipants" /&gt;
      &lt;mapping class="model.ConferenceParticipantStatus" /&gt;
      &lt;mapping class="model.ConferencesUsers" /&gt;
      &lt;mapping class="model.Location" /&gt;
      &lt;mapping class="model.User" /&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is my User class:</p>
  
  <pre><code>@Entity
  @Table( name = "Users" )
  public class User implements Serializable{
  
      private long userID;
      private int pasportID;
      private Company company; 
      private String name;
      private String email;
      private String phone1;
      private String phone2;
      private String password; //may be null/empty , will be kept hashed
      private boolean isAdmin;
      private Date lastLogin;
  
      User() {} //not public on purpose!
  
      public User(int countryID, Company company, String name, String email,
              String phone1, String phone2, String password, boolean isAdmin) {
          this.pasportID = countryID;
          this.company = company;
          this.name = name;
          this.email = email;
          this.phone1 = phone1;
          this.phone2 = phone2;
          this.password = password;
          this.isAdmin = isAdmin;
      }
  
      @Id
      @GeneratedValue(generator="increment")
      @GenericGenerator(name="increment", strategy = "increment")
      public long getUserID() {
          return userID;
      }
      public void setUserID(long userID) {
          this.userID = userID;
      }
      ...    
  }
  </code></pre>
  
  <p>Any idea why I get this error?</p>