Car.streamAll().forEach(car->saveCar((Car) car));
@Transactional(Transactional.TxType.REQUIRES_NEW)
protected void saveCar(Car car) {
car.setName("name");
car.persist();
}
The problem here of course is that im getting detached entity passed to persist, but i need to commit oftenly and not keep transaction opened, because there is lot of data and i need to commit ofttenly to not get out of space error..