Das hier ist eine kleine Testklasse, die ich habe. Problem ist, dass die Transaktion nach jedem Testlauf nicht zurückgesetzt wird. Was habe ich falsch gemacht? :)@Rollback kann nicht für meinen Spring JPA-Integrationstest verwendet werden
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/META-INF/catalog-spring.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
public class TermTest
{
@Autowired
private CatalogService service;
@Rollback(true)
@Test
public void testSimplePersist()
{
Term term = new Term();
term.setDescription("Description");
term.setName("BirdSubject8");
term.setIsEnabled("F");
term.setIsSystem("F");
term.setTermType("TERM");
service.createTerm(term);
}
}
und meine Feder Config
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="catalog2"></property>
</bean>
<bean id="catalogService" class="com.moo.catalog.service.CatalogService">
<property name="termDao" ref="termDao"></property>
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven />
I l Ove du! (Du hast aber zu schnell geantwortet, brauche noch 4 Minuten, bevor ich eine Antwort annehmen kann) – willcodejavaforfood
genau die Antwort, die ich gegeben hätte, wenn ich rechtzeitig auftauchte (+1) –
@seanizer - Ich werde deinen Kommentar zumindest auffrischen :) – willcodejavaforfood