Код: Выделить всё
"message": "No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call"При использовании @transactional это работает, я читал, что JPA использует @transactional по умолчанию
my Repository:
Код: Выделить всё
@Repository
public interface UserRepository extends JpaRepository {
void deleteByEmail(String email);
}
< /code>
my service: < /p>
@Service
public class UserService {
private final UserRepository repository;
@Autowired
public UserService(UserRepository repository) {
this.repository = repository;
}
< /code>
Мой контроллер: < /p>
@RestController
@RequestMapping("/user")
public class UserController {
private final UserService userService;
@Autowired
public UserController(UserService reviewService, UserService userService) {
this.userService = userService;
}
@Transactional
@DeleteMapping("/email/{email}")
public void deleteByEmail(@PathVariable String email){
userService.deleteByEmail(email);
}
Мой вопрос: JPA использует @transactional по умолчанию, и я делаю что -то не так, или я действительно должен явно использовать его при удалении и обновлении?>
Подробнее здесь: https://stackoverflow.com/questions/797 ... by-default