title: how to fetch data from database in Hibernate
body: <p>This is my class to fetch data from database</p>
  
  <pre><code>package com.javatpoint.mypackage;
  
  import org.hibernate.Query;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.Configuration;
  import org.hibernate.mapping.List;
  
  public class retrive {
      public static void main(String args[]) {
          Configuration cfg = new Configuration();
          cfg.configure("hibernate.cfg.xml");// populates the data of the
                                              // configuration file
  
          // creating seession factory object
          SessionFactory factory = cfg.buildSessionFactory();
  
          // creating session object
          Session session = factory.openSession();
  
          // creating transaction object
          Transaction t = session.beginTransaction();
  
          Query query = session.createQuery("from EMPLOYEE");
          java.util.List list = query.list();
          System.out.println(list);
          t.commit();
          session.close();
      }
  }
  </code></pre>
  
  <p>This is my <code>Emplouyee.hbm.xml</code> file :</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                       "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated 5 Dec, 2013 12:09:18 PM by Hibernate Tools 3.4.0.CR1 --&gt;
  &lt;hibernate-mapping default-lazy="false"&gt;
      &lt;class name="com.javatpoint.mypackage.Employee" table="EMPLOYEE"&gt;
          &lt;id name="id" type="int"&gt;
              &lt;column name="ID" /&gt;
              &lt;generator class="assigned" /&gt;
          &lt;/id&gt;
          &lt;property generated="never" lazy="false" name="firstName"
              type="java.lang.String"&gt;
              &lt;column name="FIRSTNAME" /&gt;
          &lt;/property&gt;
          &lt;property generated="never" lazy="false" name="lastName"
              type="java.lang.String"&gt;
              &lt;column name="LASTNAME" /&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>when i run this Program then following Exception come please help me how to Fix it i am new in Hibernate and trying learn but am stuck.</p>
  
  <pre><code>Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: 
             EMPLOYEE is not mapped [from EMPLOYEE]
  </code></pre>
  
  <p>while i am able to store data in database i have 2 class one for <code>String data</code> and second fetching data Problem is coming in fetching data plz help.</p>