title: Exception in thread "main" org.hibernate.MappingException: Unknown entity
body: <p>Going through the "Introduction to Hibernate" tutorials on PluralSight. I have this exception error. The full error being:</p>
  
  <pre><code>Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.simpleprogrammer.User
      at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:776)
      at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1451)
      at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:100)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
      at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
      at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
      at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:678)
      at org.hibernate.internal.SessionImpl.save(SessionImpl.java:670)
      at org.hibernate.internal.SessionImpl.save(SessionImpl.java:665)
      at com.simpleprogrammer.Program.main(Program.java:15)
  </code></pre>
  
  <p>Not sure what is wrong. I created the User.java pojo. I created a the table that matched the pojo. I created the mapping and then added the mapping to the hibernate.cfg.xml file. However, still getting the error. Can anyone help me through this?</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://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
   &lt;session-factory name=""&gt;
    &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
    &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306&lt;/property&gt;
    &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
    &lt;property name="hibernate.default_schema"&gt;protein_tracker&lt;/property&gt;
    &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
    &lt;mapping class="com.simpleprogrammer.User" resource="com/simpleprogrammer/User.hbm.xml"/&gt;
   &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Program.java</p>
  
  <pre><code>public class Program {
      public static void main(String[] args) {
          System.out.println("Hello World!");
          Session session = HibernateUtilities.getSessionFactory().openSession();
          session.beginTransaction();
  
          User user = new User();
          user.setName("Joe");
          user.setGoal(250);
          session.save(user);
  
          session.getTransaction().commit();
          session.close();
          HibernateUtilities.getSessionFactory().close();
      }
  }
  </code></pre>
  
  <p>User.hbm.xml</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 Oct 17, 2015 11:44:47 AM by Hibernate Tools 3.5.0.Final --&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="com.simpleprogrammer.User" table="USERS"&gt;
          &lt;id name="id" type="int"&gt;
              &lt;column name="ID" /&gt;
              &lt;generator class="identity" /&gt;
          &lt;/id&gt;
          &lt;property name="name" type="java.lang.String"&gt;
              &lt;column name="NAME" /&gt;
          &lt;/property&gt;
          &lt;property name="total" type="int"&gt;
              &lt;column name="TOTAL" /&gt;
          &lt;/property&gt;
          &lt;property name="goal" type="int"&gt;
              &lt;column name="GOAL" /&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>User.java</p>
  
  <pre><code>package com.simpleprogrammer;
  
  public class User {
      private int id;
      private String name;
      private int total;
      private int goal;
  
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public int getTotal() {
          return total;
      }
      public void setTotal(int total) {
          this.total = total;
      }
      public int getGoal() {
          return goal;
      }
      public void setGoal(int goal) {
          this.goal = goal;
      }
  }
  </code></pre>
  
  <p>HibernateUtilities.java</p>
  
  <pre><code>package com.simpleprogrammer;
  
  import org.hibernate.HibernateException;
  import org.hibernate.SessionFactory;
  import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  import org.hibernate.cfg.Configuration;
  import org.hibernate.service.ServiceRegistry;
  
  public class HibernateUtilities {
  
      private static SessionFactory sessionFactory;
      private static ServiceRegistry serviceRegistry;
  
      static {
          try {
              Configuration configuration = new Configuration().configure();
  
              serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
              sessionFactory = configuration.buildSessionFactory(serviceRegistry);
          }
          catch(HibernateException exception) {
              System.out.println("Problem creating session factory!");
          }   
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  }
  </code></pre>