title: Exception in thread "main" org.hibernate.MappingException: Unknown entity:
body: <p>I'm using myeclipse IDE
  After executing my code i'm getting the below Exception  </p>
  
  <pre><code>log4j:WARN No appenders could be found for logger 
  
  (org.hibernate.cfg.Environment).
  log4j:WARN Please initialize the log4j system properly.
  Exception in thread "main" org.hibernate.MappingException: Unknown entity:info.inetsolv.Emp
  at org.hibernate.impl.SessionFactoryImpl.getEntityPersister
  
  (SessionFactoryImpl.java:628)
  at org.hibernate.impl.SessionImpl.getEntityPersister
  
  (SessionImpl.java:1366)
  at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
  at org.hibernate.event.def.AbstractSaveEventListener.getEntityState
  
  (AbstractSaveEventListener.java:535)
  at org.hibernate.event.def.DefaultPersistEventListener.onPersist
  
  (DefaultPersistEventListener.java:93)
  at org.hibernate.event.def.DefaultPersistEventListener.onPersist
  
  (DefaultPersistEventListener.java:61)
  at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:646)
  at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:620)
  at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:624)
  at info.inetsolv.InsertEmprecord.main(InsertEmprecord.java:22)
  </code></pre>
  
  <p>POJO CLASS</p>
  
  <hr>
  
  <pre><code>package info.inetsolv;
  @SuppressWarnings("serial")
  public class Emp implements java.io.Serializable {
  
  // Fields
  
  private Integer eno;
  private String name;
  private Double salary;
  
  // Constructors
  
  /** default constructor */
  public Emp() {
  }
  
  /** minimal constructor */
  public Emp(Integer eno) {
      this.eno = eno;
  }
  
  /** full constructor */
  public Emp(Integer eno, String name, Double salary) {
      this.eno = eno;
      this.name = name;
      this.salary = salary;
  }
  
  // Property accessors
  
  public Integer getEno() {
      return this.eno;
  }
  
  public void setEno(Integer eno) {
      this.eno = eno;
  }
  
  public String getName() {
      return this.name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public Double getSalary() {
      return this.salary;
  }
  
  public void setSalary(Double salary) {
      this.salary = salary;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>HibernateSessionFactory.java</p>
  
  <hr>
  
  <pre><code>package info.inetsolv;
  
  import org.hibernate.HibernateException;
  import org.hibernate.Session;
  import org.hibernate.cfg.Configuration;
   public class HibernateSessionFactory {
  
  private static final ThreadLocal&lt;Session&gt; threadLocal = new 
  
  ThreadLocal&lt;Session&gt;();
  private static org.hibernate.SessionFactory sessionFactory;
  
  private static Configuration configuration = new Configuration();
  private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
  private static String configFile = CONFIG_FILE_LOCATION;
  
  static {
      try {
          configuration.configure(configFile);
  sessionFactory = configuration.buildSessionFactory();
      } catch (Exception e) {
  System.err.println("%%%% Error Creating SessionFactory %%%%");
          e.printStackTrace();
      }
  }
  private HibernateSessionFactory() {
  }
  
  public static Session getSession() throws HibernateException {
      Session session = (Session) threadLocal.get();
  
      if (session == null || !session.isOpen()) {
          if (sessionFactory == null) {
              rebuildSessionFactory();
          }
      session = (sessionFactory != null) ? sessionFactory.openSession(): null;
          threadLocal.set(session);
      }
  
      return session;
  }
  
  public static void rebuildSessionFactory() {
  try {
  configuration.configure(configFile);
  sessionFactory = configuration.buildSessionFactory();
      } catch (Exception e) {
  System.err.println("%%%% Error Creating SessionFactory %%%%");
          e.printStackTrace();
      }
  }
  
  public static void closeSession() throws HibernateException {
      Session session = (Session) threadLocal.get();
      threadLocal.set(null);
  
      if (session != null) {
          session.close();
      }
  }
  
  public static org.hibernate.SessionFactory getSessionFactory() {
      return sessionFactory;
  }
  
  public static void setConfigFile(String configFile) {
      HibernateSessionFactory.configFile = configFile;
      sessionFactory = null;
  }
  public static Configuration getConfiguration() {
      return configuration;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>client program to insert record into DB</p>
  
  <p>InsertEmprecord.java</p>
  
  <pre><code>package info.inetsolv;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.Configuration;
  
  public class InsertEmprecord {
  public static void main(String[] args) {
  
  Configuration cfg = new Configuration();
  cfg.configure();
  SessionFactory sf = cfg.buildSessionFactory();
  Session hsession = sf.openSession();
  Transaction tx = hsession.beginTransaction();
  
  Emp e = new Emp();
  e.setEno(6);
  e.setName("six");
  e.setSalary(1234d);
  hsession.persist(e);
  
  tx.commit();
  hsession.close();
  sf.close();
  
  
  }
  
  }
  </code></pre>
  
  <p>And below is my hibernate mapping file
  Emp.hbm.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 
  
  3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  
  &lt;hibernate-mapping&gt;
  &lt;class name="info.inetsolv.Emp" table="EMP" schema="HIB"&gt;
      &lt;id name="eno" type="java.lang.Integer"&gt;
          &lt;column name="ENO" precision="5" scale="0" /&gt;
          &lt;generator class="assigned" /&gt;
      &lt;/id&gt;
      &lt;property name="name" type="java.lang.String"&gt;
          &lt;column name="NAME" length="10" /&gt;
      &lt;/property&gt;
      &lt;property name="salary" type="java.lang.Double"&gt;
          &lt;column name="SALARY" precision="10" /&gt;
      &lt;/property&gt;
  &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>AND below is my hibernate configuration file</p>
  
  <p>hibernate.cfg.xml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;!-- Generated by MyEclipse Hibernate Tools.                   --&gt;
  &lt;hibernate-configuration&gt;
  
  &lt;session-factory&gt;
  &lt;property name="dialect"&gt;
      org.hibernate.dialect.Oracle9Dialect
  &lt;/property&gt;
  &lt;property name="connection.url"&gt;
      jdbc:oracle:thin:@localhost:1521:xe
  &lt;/property&gt;
  &lt;property name="connection.username"&gt;hib&lt;/property&gt;
  &lt;property name="connection.password"&gt;abc&lt;/property&gt;
  &lt;property name="connection.driver_class"&gt;
      oracle.jdbc.driver.OracleDriver
  &lt;/property&gt;
  &lt;property name="myeclipse.connection.profile"&gt;
      my oracle drive
  &lt;/property&gt;
  &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
  &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>