개인프로젝트/mix
Repository.findbyid 해결
슬픈강낭콩
2023. 1. 20. 09:19
상황은 해당 테이블에 id와 core_name 둘다 pk로 선언되어있고 ID를 core_id로 allCoreRepository.findById(allcore.getCore_name()); 를 전송했다. ID로 매칭을 해서그런가 Repository 로 만들때는 String타입으로 전송해서 잘 될줄 알았다. 근데 @id값을 String으로 바꾸니까 해결되었다.
public interface AllCoreRepository extends JpaRepository<Allcore, String> {
}
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private int core_id;
private String core_name;
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private String core_name;
private int core_id;