I have a very weird situation.
In my for loop I have:
<code>public List<Event> changeSth(
for (TimeWindow updatedTimeWindow : updatedTimeWindows) {
try {
timeWindowAndAnnouncementEvents.addAll(facade.updateTimeWindow(updatedTimeWindow, modifyingCompany));
} catch (Exception ex) {
}
}
</code>
<code>public List<Event> changeSth(
for (TimeWindow updatedTimeWindow : updatedTimeWindows) {
try {
timeWindowAndAnnouncementEvents.addAll(facade.updateTimeWindow(updatedTimeWindow, modifyingCompany));
} catch (Exception ex) {
}
}
</code>
public List<Event> changeSth(
for (TimeWindow updatedTimeWindow : updatedTimeWindows) {
try {
timeWindowAndAnnouncementEvents.addAll(facade.updateTimeWindow(updatedTimeWindow, modifyingCompany));
} catch (Exception ex) {
}
}
and:
<code>@Service
public class Facade {
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Event> updateSth(
...
service.updateRoute(updatedTimeWindow);
...
</code>
<code>@Service
public class Facade {
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Event> updateSth(
...
service.updateRoute(updatedTimeWindow);
...
</code>
@Service
public class Facade {
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<Event> updateSth(
...
service.updateRoute(updatedTimeWindow);
...
And:
<code>@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateRoute(TimeWindow timeWindow) {
Optional<Route> oldRoute = routeRepository.findRouteById(timeWindow.getRoute().getId());
oldRoute.ifPresent(route -> {
updateSpots(timeWindow, route); // route object is updated and should be saved after transaction ends up
});
}
</code>
<code>@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateRoute(TimeWindow timeWindow) {
Optional<Route> oldRoute = routeRepository.findRouteById(timeWindow.getRoute().getId());
oldRoute.ifPresent(route -> {
updateSpots(timeWindow, route); // route object is updated and should be saved after transaction ends up
});
}
</code>
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateRoute(TimeWindow timeWindow) {
Optional<Route> oldRoute = routeRepository.findRouteById(timeWindow.getRoute().getId());
oldRoute.ifPresent(route -> {
updateSpots(timeWindow, route); // route object is updated and should be saved after transaction ends up
});
}
I have 2 objects in updatedTimeWindows
, 2 iterations in for loop. After first iteration everything is OK, data are updated in the first row of table Spot
. But after second iteration not only the second row is updated but there is update query that sets the old data to my first row of my table. Why?