1

フィールドを持つエンティティを作成しました

entity jpa --class ~.domain.Account
field string --fieldName email
field string --fieldName password

リポジトリを作成したとき

リポジトリ jpa --interface ~.repositories.AccountRepository --entity ~.domain.Account

リポジトリにファインダーを追加したいのですが、エンティティーにファインダーを追加するのと同様にファインダーを追加する方法はありますか?

finder add findAccountsByEmail
4

1 に答える 1

2

ファインダは、アクティブなレコード エンティティでのみ使用できます。リポジトリを使用してクエリを生成するには、リポジトリ クラスで新しいメソッドを作成し、 @Query アノテーションで装飾し、JPQL を使用してクエリを記述します。あなたの例は次のようになります。

@Query("select a from Account as a where a.email = :email")
@Transactional(readOnly = true)
List<Account> findAccountsByEmail(@Param("email") String email)
于 2012-05-29T23:01:01.687 に答える