title: Spring data updates entity without transaction
body: <p>I have simple code example with Spring Data:</p>
  
  <p>Entity</p>
  
  <pre><code>@Entity
  @Table(name = "car")
  public class Car {
  
      @Id
      @GeneratedValue
      private Long id;
  
      private String name;
  //...
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface CarRepository extends JpaRepository&lt;Car, Long&gt; {
  }
  </code></pre>
  
  <p>Service with example methods:</p>
  
  <pre><code>@Service
  public class CarService {
  
      @Autowired
      private CarRepository carRepository;
  
      public void change() {
          Car one = carRepository.findOne(1L);
          one.setName("changed"); //important
      }
  }
  </code></pre>
  
  <p>And controller:</p>
  
  <pre><code>@RestController("/")
  public class CarController {
  
      @Autowired
      private CarRepository carRepository;
  
      @Autowired
      private CarService carService;
  
      @GetMapping
      public List&lt;Car&gt; home() {
          carService.change();
          List&lt;Car&gt; all = carRepository.findAll();
  
          return all;
      }
  
  }
  </code></pre>
  
  <p>I also have data.sql with 3 records:</p>
  
  <pre><code>insert into car values (1, 'aaa');
  insert into car values (2, 'bbb');
  insert into car values (3, 'ccc');
  </code></pre>
  
  <p>When I send request to the localhost:8080 I get list with three cars, where the first one is updated:</p>
  
  <pre><code>insert into car values (1, 'changed');
  insert into car values (2, 'bbb');
  insert into car values (3, 'ccc');
  </code></pre>
  
  <p>My expectation is that after calling change() from controller actually nothing happens because this method is not transactional. So why my home() method in controller returns list with updated entity?</p>
  
  <p>This question is completly different from this <a href="https://stackoverflow.com/questions/19716673/spring-data-jpa-transactional">Spring data jpa @transactional</a> I don't understand why you mark this as duplicate.</p>