Hi
I am using AbstractJpaTests, the test passes successfully, however, after it finishes, I look into the database and the test record is still there. My application.xml looks like this:
My test looks like this:Code:<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost/dac" /> <property name="username" value="dacUser" /> <property name="password" value="dacUser" /> </bean> <!-- JPA EntityManagerFactory --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect"/> <property name="generateDdl" value="true"/> <property name="showSql" value="true" /> </bean> </property> </bean> <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> <property name="dataSource" ref="dataSource"/> </bean> <!-- Instruct Spring to perform declarative transaction management automatically on annotated classes. --> <tx:annotation-driven/> <!-- PostProcessors to perform resource injection according to the JPA specification (@PersistenceContext, @PersistenceUnit). --> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <!-- PostProcessors to perform exception translation on @Repository classes (from native exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy). --> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> <bean id="clinicDao" class="org.springframework.samples.petclinic.jpa.JpaTemplateClinic"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean>
The JpaTemplateClinic has no annotations, the persistent class Manvita uses annotations.Code:public class ClinicIntegrationTest extends AbstractJpaTests { protected JpaTemplateClinic jpaTemplateClinic; protected String[] getConfigLocations(){ return new String[] {"classpath:/applicationContext.xml"}; } public void testInserts() throws Exception { Manvita m = new Manvita(); m.setName("paruchuri"); jpaTemplateClinic.storeAny(m); Collection<Manvita> manvitas = jpaTemplateClinic.findManvitas(); assertEquals("Wrong number", 1, manvitas.size()); } public void setClinicDao(JpaTemplateClinic jpaTemplateClinic) { this.jpaTemplateClinic = jpaTemplateClinic; } }


Reply With Quote
.

