存储库类
package jerceka.workhard.demo;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
@Repository
@RepositoryRestResource(collectionResourceRel="account",path="account")
public interface Repo extends JpaRepository<Account, Integer>{
List<Account> findByage(int age);
List<Account> findByname(String name);
List<Account> deleteByName(String name);
}
控制器类
package jerceka.workhard.demo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AccountController {
@Autowired
private Repo repo;
@DeleteMapping("Account/{name}")
public List<Account> deleteWithName(@PathVariable("name")String name){
repo.deleteByName(name);
return repo.findAll();
}
}
给我那个错误 没有用于当前线程的具有实际事务的EntityManager-无法可靠地处理“删除”调用