title: Connection cannot be null hibernate exception
body: <p>I'm a newbie to hibernate . I get this exception "Connection cannot be null when hibernate.dialect is not set" when i try to run it. I've set the dialect properly. </p>
  
  <p>This is the hibernate.cfg.xml file</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
  &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&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/mysql&lt;/property&gt;
  &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
  &lt;property name="hibernate.connection.password"&gt;admin&lt;/property&gt;
  &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;
  &lt;property name="show_sql"&gt;true&lt;/property&gt;
  &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
  
  &lt;mapping class="org.siva.model.UserDetails"/&gt;
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>The model class.</p>
  
  <pre><code>@Entity
  public class UserDetails {
    @Id
    private int userID;
    private String userName;
  
    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;
    }
  }
  </code></pre>
  
  <p>The main class</p>
  
  <pre><code>public class HibernateTest {
  
  public static void main(String[] args) {
     UserDetails user=new UserDetails();
     user.setUserID(1);
     user.setUserName("firstUser");
     Configuration configuration=new Configuration();
     ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
     SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
     Session session=sessionFactory.openSession();
     session.beginTransaction();
     session.save(user);
     session.getTransaction().commit();
  
  }
  </code></pre>
  
  <p>}</p>