Hibernate 5.0.7 Configuration: entity not loaded
<p>I'm using Hibernate 5.0.7 and I've a problem with annotation configuration. </p>

<p>This is my hibernate.cfg.xml file:</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.org/dtd/hibernate-configuration-3.0.dtd"&gt; 
&lt;hibernate-configuration&gt;
&lt;session-factory&gt;

    &lt;property name="hibernate.connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt;
    &lt;property name="hibernate.connection.url"&gt;jdbc:sqlserver://localhost:1433;DatabaseName=mydb&lt;/property&gt;
    &lt;property name="hibernate.connection.username"&gt;sa&lt;/property&gt;
    &lt;property name="hibernate.connection.password"&gt;sa&lt;/property&gt;

    &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
    &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;

    &lt;mapping class="com.domain.Person"/&gt;

&lt;/session-factory&gt;
</code></pre>

<p></p>

<p>I configure the session factory in this way:</p>

<pre><code>    Configuration configuration = new Configuration();
    configuration.configure("hibernate.cfg.xml");

    ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();

    SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);

    return sessionFactory;
</code></pre>

<p>When I try to execute a query on Person class I obtained an empty list. I discovered that the class Person is not loaded properly in the session factory (sessionFactory.getAllClassMetadata() returns empty list) and the only way to do that is to add manually the class:</p>

<pre><code> configuration.addAnnotatedClass(Person.class);
</code></pre>

<p>How can I solve?</p>