0
그래서 JPARepository를 사용하여 Postgres DB에 객체를 커밋하는 스프링 부트 애플리케이션이 있습니다. 내 저장소에 대한 코드는 다음과 같습니다 : 스프링 부트 JPARepository - postgres 테이블을 업데이트하는 방법
public interface TestObjectDao extends JPARepository<TestObject, Long> {
List<TestObject> findByTestRefIdAndTestType(String testRefId,
Short testType);
TestObject save(TestObject testObject);
}
내가 만들
, 내 서비스 구현에서 나는 방법을 "저장"을 사용 (인터페이스 위에 구현). 그러나 업데이트하려고하면 항목을 만들거나 업데이트하지 않습니다.누구나 prostgres db에서 레코드를 업데이트하는 방법을 알려줄 수 있습니까?
@Component
public class TestObjectServiceImpl implements TestObjectService {
@Inject
private TestObjectDao TestObjectDao;
@Override
public TestObjectResponse createTestObject(String testRefId, String testType, TestObject testObject) throws Exception{
--
--
--
try {
//update object
testObject = TestObjectDao.save(testObject);
}
}
catch (Exception ex) {
throw new Exception("Object could not be modified");
}
TestObjectResponse testObjectResponse = new TestObjectResponse();
testObjectResponse.setVal(testObject);
return testObjectResponse;
}
}
나는 모든 관련 게시물이 겪었지만 만족스러운 해결책을 얻을 didnt는 : 다음 업데이트를 사용하여 내 코드입니다.
빠른 답변을 보내 주시면 더 자세한 정보가 필요하시면 알려 주시기 바랍니다. 이 저장하거나 ID를 확인하여 엔티티를 생성 할 필요가 어떠했는지
감사
감사합니다. Alexey !!!! 너는 내 하루를 보냈다. 레코드를 업데이트 중입니다. – user5423592
듣기가 좋습니다. 그런 다음 정답으로 표시하십시오. –