title: How to swap out hibernate.cfg.xml properties?
body: <p>I've got a <em>Hibernate</em> configuration file <code>hibernate.cfg.xml</code> where are hard-coded property names like:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
    &lt;session-factory&gt;
      &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;mysecretpassword&lt;/property&gt;
      ...
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I want to swap out things like the username and the password to a <code>.properties</code>-file. So that I will get the following:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
    &lt;session-factory&gt;
      &lt;property name="hibernate.connection.username"&gt;${jdbc.username}&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;${jdbc.password}&lt;/property&gt;
      ...
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>How can I do that? For the <strong>dataSource in Spring</strong> I can use this one in my <code>applicationContext.xml</code>:</p>
  
  <pre><code>&lt;bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
        p:location="/WEB-INF/jdbc.properties" /&gt;
  </code></pre>
  
  <p><em>What is the equivalent for Hibernate?</em></p>