2017-11-15 19 views
2

おはよう!春データ1.11.7プロパティがありません。

マイSpringアプリケーションがリポジトリにexistsByの予測

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property existsById found for type Planet! 
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) 
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) 
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) 
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) 

コードを検出していないようだ

public boolean existsByIdAndOwnerId(Long planetId, Integer ownerId);

  • 春バージョン:4.3.12.RELEASE
  • Hibernateのバージョン:5.2.12.Final
  • 春データJPAバージョン:1.11.7.RELEASE

ありがとうございます!

+0

https://stackoverflow.com/a/26539097/8906016あなたは(すなわち 'パブリックブールfindByIdAndOwnerId(ロングplanetId、整数OWNERIDによってfindByの代わりが存在を使用する必要が – canillas

+0

それをチェック); ')。 – Hiren

答えて

0

CrudRepository<T, ID>をリポジトリで拡張する場合、existById(ID)はidをパラメータとして使用し、dbエントリの存在に基づいてブール値を返します。あなたのケースのために、あなたは次のように行うことができます。public boolean findByIdAndOwnerId(Long planetId, Integer ownerId);

+0

このコードは機能しません。「アドバイスからのヌル戻り値がプリミティブの戻り値の型と一致しません」というエラーを返します。 "findById .."メソッド(これはブール値ではなくその型のオブジェクトを返す)からヌル値を検出すると "false"を返すラッパーメソッドを作成する必要があります。 –

関連する問題