Note that there are some explanatory texts on larger screens.

plurals
  1. POTesting Spring-JPA
    primarykey
    data
    text
    <p>I am developping a web application using Spring (3.1.x), JSF 2, JPA 2 (Hibernate Provider) for tomcat 6.x. I want to test my DAO classes.</p> <p>In my DAO class: i do this:</p> <pre class="lang-java prettyprint-override"><code>@PersistenceContext private EntityManager entityManager; </code></pre> <p>In Spring Configuration;</p> <pre class="lang-xml prettyprint-override"><code>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt; &lt;property name="persistenceUnitName" value="OpenPU" /&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt; &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt; &lt;/bean&gt; </code></pre> <p>In persistence.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;persistence-unit name="OpenPU" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;non-jta-data-source&gt;java:comp/env/jdbc/mysql_open&lt;/non-jta-data-source&gt; &lt;properties&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" /&gt; &lt;property name="hibernate.show_sql" value="true"/&gt; &lt;property name="hibernate.transaction.flush_before_completion" value="true"/&gt; &lt;property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/&gt; &lt;property name="hibernate.connection.zeroDateTimeBehavior" value="convertToNull"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>It the first time I make test, and when I test I don't want to use the same persistence unit. I heard about dbunit for using xml data, but i don't understand how to change the persistence unit during the test. Can you help me or give me some example, tutorial.</p> <p>Thanks you.</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.
 

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