title: persistence.xml to import database parameters values from .properties file
body: <p>Edit: <a href="https://stackoverflow.com/q/17044604/597349">not duplicate but almost</a></p>
  
  <p>I would like to have my app persistence.xml to be something like</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
                  http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
                  version="1.0"&gt;
     &lt;persistence-unit name="appName" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.dialect" value="${db.dialect'}"/&gt;
              &lt;property name="javax.persistence.jdbc.driver" value="${db.driver}"/&gt;
              &lt;property name="javax.persistence.jdbc.user" value="${db.user}"/&gt;
              &lt;property name="javax.persistence.jdbc.password" value="${db.password}"/&gt;
              &lt;property name="javax.persistence.jdbc.url" value="${db.url}"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>getting these placeholder values from a simple text file somewhere in my source folders.</p>
  
  <p>I read about that it's possible when using Spring doing like</p>
  
  <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="locations"&gt;
          &lt;value&gt;classpath:com/foo/jdbc.properties&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>but here we are not using Spring, just Hibernate and some Primefaces.</p>
  
  <p>Is it possible?</p>
  
  <p>Thanks!</p>
  
  <p>Edit: I didn't mention some things, but for reference, I'm also using Shiro Security and Ant to do some stuff. I'll post the solution as an answer. This makes my project have 3 different files with database parameters:</p>
  
  <ul>
  <li>persistence.xml (Hibernate)</li>
  <li>context.xml (Shiro)</li>
  <li>database.properties (for Flyway tasks in Ant)</li>
  </ul>