Use @Transactional where appropriate
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user