Hi,
I am creating a test cases for my spring services used with EclipseLink JPA.
I am extending from AbstractJpaTests. I am using two services within a single test wherein one service inserts some data and another service retrieves the data.
AFAIK the transactions done within tests are rolled back after the test case is over. However within a test case various service methods participating in the transaction should join the same transaction otherwise it wouldn't get the data changes done by the previous service method call.
However in my case the second service is not able to see the data. I am sure it's in a different transaction than the original one. But I am not able to figure out how.
Could somebody please help me here?
My test class looks like
Thanks in advance,Code:@ContextConfiguration(locations = { "classpath:beans-config.xml" }) public class TestClass extends AbstractJpaTests { ...... ...... @Test public void test1(){ service1.save(aentity); // 1 someClass.method1(); } } public class SomeClass { public void method1(){ //Here I am passing correct query and parameters for finding the //entity //inserted at 1 service1.findEntity(query, parameters); //I get exception here for no result } } public class Service1 { @Transactional (readOnly = true, propagation = Propagation.REQUIRED) public void findEntity(String query, Object[] parameters){ ...... } }
Shashi


Reply With Quote

