title: Hibernate 5 :- org.hibernate.MappingException: Unknown entity
body: <p>I am getting the error message <code>org.hibernate.MappingException: Unknown entity</code> when i am trying to integrate hibernate 5.0 with mysql</p>
  
  <p>This seems to be an issue with hibernate5.0.0 and 5.0.1 . This works fine with hibernate 4.3.9</p>
  
  <h3>Maven dependices</h3>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;5.0.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.36&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <h3>hibernate.cfg.xml</h3>
  
  <p></p>
  
  <pre><code>&lt;session-factory&gt;
  
      &lt;!-- Database connection settings --&gt;
      &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3307/SampleDB
      &lt;/property&gt;
      &lt;property name="connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;&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="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  
      &lt;mapping class="UserA.User"&gt;&lt;/mapping&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <h3>HibernateMain.java code</h3>
  
  <pre><code>package UserA;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  import org.hibernate.cfg.Configuration;
  import org.hibernate.mapping.Map;
  import org.hibernate.metadata.ClassMetadata;
  import org.hibernate.persister.entity.EntityPersister;
  import org.hibernate.service.ServiceRegistry;
  
  public class HibernateMain {
  
      public static void main(String[] args) {
  
          Configuration configuration = new Configuration();
          configuration.configure();
          ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
  
          SessionFactory sf = configuration.buildSessionFactory(sr);
  
  
  
  
          User user1 = new User();
          user1.setUserName("Arpit");
          user1.setUserMessage("Hello world from arpit");
          user1.setUserId(22);
  
          Session ss = sf.openSession();
          ss.beginTransaction();
          // saving objects to session
          ss.save(user1);
          ss.getTransaction().commit();
          ss.close();
  
      }
  
  }
  </code></pre>
  
  <h3>User.java</h3>
  
  <pre><code>package UserA;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity(name="User_table")
  public class User {
      @Id
      int userId;
      @Column(name = "User_Name")
      String userName;
  
      @Column(name = "User_Message")
      String userMessage;
  
      public int getUserId() {
          return userId;
      }
  
      public void setUserId(int userId) {
          this.userId = userId;
      }
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getUserMessage() {
          return userMessage;
      }
  
      public void setUserMessage(String userMessage) {
          this.userMessage = userMessage;
      }
  
  }
  </code></pre>