Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sean, all </p> <p>I had the same problem and found one more thing which might be useful to all. In persistence.xml one can define multiple persistence-unit with different names like:</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt; &lt;!-- production persistence unit --&gt; &lt;persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL"&gt; ... &lt;/persistence-unit&gt; &lt;!-- test persistence unit --&gt; &lt;persistence-unit name="testPersistenceUnit" transaction-type="RESOURCE_LOCAL"&gt; ... &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>Then in your applicationContext.xml (this one for tests )only 2 changes are needed:</p> <ol> <li><p>properties files are loaded form META-INF/spring-test/*</p> <pre><code>&lt;context:property-placeholder location="classpath*:META-INF/spring-test/*.properties"/&gt; </code></pre></li> <li><p>persistenceUnitName points to "testPersistenceUnit" in persistance.xml</p> <pre><code>&lt;bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory"&gt; &lt;property name="persistenceUnitName" value="testPersistenceUnit"/&gt; &lt;property name="dataSource" ref="dataSource"/&gt; </code></pre> <p></p></li> </ol> <p>Hope this will help someone as there is many answers there but it is hard to find out that you can have multiple persistenceUnits defined in one persistence.xml</p> <p>Szymon</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload