私は自分のアプリケーションに春データの残りを使用しています。リストの返品方法<String>または春のスプリングデータの残り
私は自分のリポジトリで次のメソッドを使用しています。
public interface TestRepository() extends BaseRepository<TestTerm, Integer>{
@Query("select distinct tt.term from TestTerm")
List<String> findDistinctTerm();
}
私は上記の方法を実行します。私はどのように私はこの問題を解決することができ、エラー、次のSpring Data Rest (SDR) bug? Persistent Entity Must not be null
に関連
PersistentEntity must not be null
質問を取得していますか?
このために個別の実装を記述する必要はありますか?もしそうなら誰も私のためにこれの例を教えてくれますか?
アップデート: - :
@Query("select DISTINCT term from ForbiddenTerm")
List<TestTerm> findDistinctByTerm();
エラー: - -
{ "原因":ヌル、 「私はこの
方法1のように試してみました
メッセージ ":" PersistentEntityはnullであってはいけません! " }
方法2: -
List<TestTerm> findDistinctByTerm();
エラー: -
... 154 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forbiddenTermRepository': Invocation of init method failed; nested exception is java.util.NoSuchElementException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
... 175 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forbiddenTermRepository': Invocation of init method failed; nested exception is java.util.NoSuchElementException
「TestTerm」タイプの登録済みエンティティのみを返すことができるため、SDRで(直接)アクセスすることはできません。このリポジトリを使用する別のコントローラを宣言する必要があります。 – kuhajeyan
別途実装する必要はありません。ちなみに、あなたはSpring Bootを使っていますか? –
'@Query(" TestTerm ttから別のtt.termを選択 ")'を実行するか、または:@Query( "TestTerm ttから別のttを選択") 'を実行し、' TestTerm'エンティティのリストを返し、リスト –