JPARepositoryを使用してPostgres DBにオブジェクトをコミットするSpringブートアプリケーションがあります。私のリポジトリのためのコードは以下の通りです:Springブート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;
}
}
私はすべての関連記事を読み終えましたが、満足のいく解決を得られませんでした。
クイックレスポンスは非常に高く評価され、誰かが詳細を必要としている場合はお知らせください。それはそれのIDをチェックして、エンティティを保存するか、作成する必要が天気を
おかげ
ありがとうございましたAlexey !!!!あなたは私の一日を作った。レコードが更新されました。 – user5423592
聞いて幸いです。正しい答えとしてマークしてください。 –