I have a job(java based application and not spring batch) which process a list of members.For each member it perform some operations through service1 and service2. Now Service1 has method m1() having @Transactional(readOnly = false, value = "txManager", propagation = Propagation.REQUIRES_NEW). This method gets the entity and calls some of the setter method to update the entity and passes to Service2.m2(entity e) which is also having @Transactional(readOnly = false, value = "txManager", propagation = Propagation.REQUIRES_NEW). This is working fine as i am not getting detached issue in method m2.
Now the same services are part of web application which is exposing rest services. While i call those rest service through junit (POST), detached issue is coming in method m2. Flow is same in both the cases as m1 is calling m2. I found that it could be because of PersistenceContextType.EXTENDED , which is solving the issue in second case but i am not sure why its working in the first case when it is not PersistenceContextType.EXTENDED. I also tried opensessioninview filter but its also not working.Below is the junit test.
SomeMemberObject memberObject=new SomeMemberObject ("name","age");
String response = LocalRestClientInvoker.invoke("http://localhost:8080/someRestService","/saveInfo",memberObject,MethodType.POST);
LoaclRestClientInvoker is using RestTemplate to call POST method.