mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Use @Transactional where appropriate
This commit is contained in:
parent
fa998287ab
commit
7006f222ab
@ -19,6 +19,7 @@ package org.springframework.boot.sample.data.jpa.web;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.sample.data.jpa.service.CityService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@ -30,6 +31,7 @@ public class SampleController {
|
||||
|
||||
@RequestMapping("/")
|
||||
@ResponseBody
|
||||
@Transactional(readOnly = true)
|
||||
public String helloWorld() {
|
||||
return this.cityService.getCity("Bath", "UK").getName();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user