title: Hibernate dynamic entity model
body: <p>I am creating a Java application that utilizes a JPA annotated model - the core model -. On top of these entities, at runtime, I would like to add a jar file from an external source that contains some other JPA classes definitions and mappings. The imported archive might change its class structure and mappings, but it is the application's duty to refresh the entire schema when changed.</p>
  
  <p>However, when trying to add the jar to hibernate Configuration, I get a</p>
  
  <pre><code>  org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  </code></pre>
  
  <p>The inner exception is related to the hibernate dialect:</p>
  
  <pre><code>org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  </code></pre>
  
  <p>However, I am sure to have specified the <code>hibernate.dialect</code> property in the <code>persistence.xml</code> file. Below is the code I am using in my application:</p>
  
  <pre><code>org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
  cfg.addJar(new File("path/to/jar.jar"));
  cfg.buildSessionFactory();
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Also, could you please tell me if you find this a good approach to create a dynamically updateable schema shared between multiple applications?</p>