クラス SimpleJpaRepository<T,ID>
java.lang.ObjectSE
org.springframework.data.jpa.repository.support.SimpleJpaRepository<T,ID>
- 型パラメーター:
T
- 処理するエンティティの型ID
- エンティティの識別子の型
- 実装されたすべてのインターフェース:
JpaRepository<T,
、ID> JpaSpecificationExecutor<T>
、JpaRepositoryConfigurationAware
、JpaRepositoryImplementation<T,
、ID> CrudRepository<T,
、ID> ListCrudRepository<T,
、ID> ListPagingAndSortingRepository<T,
、ID> PagingAndSortingRepository<T,
、ID> QueryByExampleExecutor<T>
、Repository<T,
ID>
- 既知の直属サブクラス
QuerydslJpaRepository
@Repository
@Transactional(readOnly=true)
public class SimpleJpaRepository<T,ID>
extends ObjectSE
implements JpaRepositoryImplementation<T,ID>
CrudRepository
インターフェースのデフォルト実装。これにより、プレーンな EntityManager
よりも洗練されたインターフェースが提供されます。- 作成者:
- Oliver Gierke, Eberhard Wolff, Thomas Darimont, Mark Paluch, Christoph Strobl, Stefan Fussenegger, Jens Schauder, David Madden, Moritz Becker, Sander Krabbenborg, Jesse Wouters, Greg Turnquist, Yanming Zhou, Ernst-Jan van der Laan, Diego Krupitza, Seol-JY, Joshua Chen
ネストされたクラスのサマリー
インターフェース org.springframework.data.jpa.repository.JpaSpecificationExecutor から継承されたネストクラス / インターフェース
JpaSpecificationExecutor.SpecificationFluentQuery<T>
コンストラクターの概要
コンストラクターコンストラクター説明SimpleJpaRepository
(ClassSE<T> domainClass, jakarta.persistence.EntityManager entityManager) 指定されたドメイン型のオブジェクトを管理する新しいSimpleJpaRepository
を作成します。SimpleJpaRepository
(JpaEntityInformation<T, ?> entityInformation, jakarta.persistence.EntityManager entityManager) 指定されたJpaEntityInformation
のオブジェクトを管理する新しいSimpleJpaRepository
を作成します。メソッドのサマリー
修飾子と型メソッド説明long
count()
<S extends T>
longlong
count
(Specification<T> spec) 指定されたSpecification
が返すインスタンスの数を返します。long
delete
(Specification<T> spec) Specification
によって削除し、削除された行数を返します。void
void
void
deleteAll
(IterableSE<? extends T> entities) void
deleteAllById
(IterableSE<? extends ID> ids) void
deleteAllByIdInBatch
(IterableSE<ID> ids) 単一のクエリを使用して、指定された ID で識別されるエンティティを削除します。void
バッチ呼び出しですべてのエンティティを削除します。void
deleteAllInBatch
(IterableSE<T> entities) 指定されたエンティティをバッチで削除します。これは、単一のクエリを作成することを意味します。void
deleteById
(ID id) <S extends T>
booleanboolean
exists
(Specification<T> spec) データストアに、指定されたSpecification
と一致する要素が含まれているかどうかを確認します。boolean
existsById
(ID id) findAll()
findAll
(Specification<T> spec) 指定されたSpecification
に一致するすべてのエンティティを返します。findAll
(Specification<T> spec, Pageable pageable) 指定されたSpecification
に一致するエンティティのPage
を返します。findAll
(Specification<T> spec, Sort sort) 指定されたSpecification
およびSort
に一致するすべてのエンティティを返します。findAll
(Specification<T> spec, Specification<T> countSpec, Pageable pageable) 指定されたSpecification
に一致するエンティティのPage
を返します。findAllById
(IterableSE<ID> ids) <S extends T,
R>
RfindBy
(Example<S> example, FunctionSE<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) <S extends T,
R>
RfindBy
(Specification<T> spec, FunctionSE<? super JpaSpecificationExecutor.SpecificationFluentQuery<S>, R> queryFunction) クエリとその結果の型を定義するqueryFunction
を適用して、指定されたSpecification
に一致するエンティティを返します。<S extends T>
OptionalSE<S>findOne
(Specification<T> spec) 指定されたSpecification
またはOptional.empty()
に一致する単一のエンティティが見つからない場合、それを返します。void
flush()
データベースに対するすべての保留中の変更をフラッシュします。使用すべきではありません。getCountQuery
(Specification<S> spec, ClassSE<S> domainClass) 指定されたSpecification
の新しいカウントクエリを作成します。protected jakarta.persistence.TypedQuery<LongSE>
getCountQuery
(Specification<T> spec) 使用すべきではありません。使用すべきではありません。protected <S extends T>
jakarta.persistence.TypedQuery<S>getQuery
(Specification<S> spec, ClassSE<S> domainClass, Pageable pageable) 指定されたSpecification
から新しいTypedQuery
を作成します。protected <S extends T>
jakarta.persistence.TypedQuery<S>getQuery
(Specification<S> spec, ClassSE<S> domainClass, Sort sort) protected jakarta.persistence.TypedQuery<T>
getQuery
(Specification<T> spec, Pageable pageable) 指定されたSpecification
から新しいTypedQuery
を作成します。protected jakarta.persistence.TypedQuery<T>
getQuery
(Specification<T> spec, Sort sort) protected QueryHints
protected QueryHints
カウントクエリの現在のCrudMethodMetadata
に関するクエリヒントを含むQueryHints
を返します。getReferenceById
(ID id) 指定された識別子を持つエンティティへの参照を返します。protected CrudMethodMetadata
readPage
(jakarta.persistence.TypedQuery<S> query, ClassSE<S> domainClass, Pageable pageable, Specification<S> spec) readPage
(jakarta.persistence.TypedQuery<T> query, Pageable pageable, Specification<T> spec) 使用すべきではありません。代わりにreadPage(TypedQuery, Class, Pageable, Specification)
を使用してください<S extends T>
Ssave
(S entity) saveAll
(IterableSE<S> entities) saveAllAndFlush
(IterableSE<S> entities) すべてのエンティティを保存し、変更を即座にフラッシュします。<S extends T>
SsaveAndFlush
(S entity) エンティティを保存し、変更を即座にフラッシュします。void
setEscapeCharacter
(EscapeCharacter escapeCharacter) リポジトリで使用するEscapeCharacter
を構成します。void
setProjectionFactory
(ProjectionFactory projectionFactory) リポジトリで使用するProjectionFactory
を構成します。void
LockModeType
を検出するために使用されるカスタムCrudMethodMetadata
と、クエリに適用されるクエリヒントを構成します。クラス java.lang.ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE
インターフェース org.springframework.data.jpa.repository.JpaRepository から継承されたメソッド
deleteInBatch
コンストラクターの詳細
SimpleJpaRepository
public SimpleJpaRepository(JpaEntityInformation<T, ?> entityInformation, jakarta.persistence.EntityManager entityManager) 指定されたJpaEntityInformation
のオブジェクトを管理する新しいSimpleJpaRepository
を作成します。- パラメーター:
entityInformation
- null であってはなりません。entityManager
- null であってはなりません。
SimpleJpaRepository
指定されたドメイン型のオブジェクトを管理する新しいSimpleJpaRepository
を作成します。- パラメーター:
domainClass
- null であってはなりません。entityManager
- null であってはなりません。
メソッドの詳細
setRepositoryMethodMetadata
LockModeType
を検出するために使用されるカスタムCrudMethodMetadata
と、クエリに適用されるクエリヒントを構成します。- 次で指定:
- インターフェース
JpaRepositoryConfigurationAware
のsetRepositoryMethodMetadata
- パラメーター:
metadata
-
setEscapeCharacter
インターフェースからコピーされた説明:JpaRepositoryConfigurationAware
リポジトリで使用するEscapeCharacter
を構成します。- 次で指定:
- インターフェース
JpaRepositoryConfigurationAware
のsetEscapeCharacter
- パラメーター:
escapeCharacter
- null であってはなりません。
setProjectionFactory
インターフェースからコピーされた説明:JpaRepositoryConfigurationAware
リポジトリで使用するProjectionFactory
を構成します。- 次で指定:
- インターフェース
JpaRepositoryConfigurationAware
のsetProjectionFactory
- パラメーター:
projectionFactory
- null であってはなりません。
getRepositoryMethodMetadata
getDomainClass
deleteById
- 次で指定:
- インターフェース
CrudRepository<T,
のID> deleteById
delete
- 次で指定:
- インターフェース
CrudRepository<T,
のID> delete
deleteAllById
- 次で指定:
- インターフェース
CrudRepository<T,
のID> deleteAllById
deleteAllByIdInBatch
インターフェースからコピーされた説明:JpaRepository
単一のクエリを使用して、指定された ID で識別されるエンティティを削除します。この種の操作では、JPA の第 1 レベルのキャッシュとデータベースが同期しなくなります。このメソッドを呼び出す前に、EntityManager
をフラッシュすることを検討してください。- 次で指定:
- インターフェース
JpaRepository<T,
のID> deleteAllByIdInBatch
- パラメーター:
ids
- 削除するエンティティの ID。null であってはなりません。
deleteAll
- 次で指定:
- インターフェース
CrudRepository<T,
のID> deleteAll
deleteAllInBatch
インターフェースからコピーされた説明:JpaRepository
指定されたエンティティをバッチで削除します。これは、単一のクエリを作成することを意味します。この種の操作では、JPA の第 1 レベルのキャッシュとデータベースが同期しなくなります。このメソッドを呼び出す前に、EntityManager
をフラッシュすることを検討してください。また、JPA のカスケードセマンティクスは尊重されず、JPA ライフサイクルイベントも発行されません。
- 次で指定:
- インターフェース
JpaRepository<T,
のID> deleteAllInBatch
- パラメーター:
entities
- 削除するエンティティ。null であってはなりません。
deleteAll
- 次で指定:
- インターフェース
CrudRepository<T,
のID> deleteAll
deleteAllInBatch
インターフェースからコピーされた説明:JpaRepository
バッチ呼び出しですべてのエンティティを削除します。- 次で指定:
- インターフェース
JpaRepository<T,
のID> deleteAllInBatch
findById
- 次で指定:
- インターフェース
CrudRepository<T,
のID> findById
getOne
使用すべきではありません。インターフェースからコピーされた説明:JpaRepository
指定された識別子を持つエンティティへの参照を返します。JPA 永続性プロバイダーの実装方法によっては、これは常にインスタンスを返し、最初のアクセスでEntityNotFoundException
をスローする可能性が非常に高くなります。それらのいくつかは、無効な識別子をすぐに拒否します。- 次で指定:
- インターフェース
JpaRepository<T,
のID> getOne
- パラメーター:
id
- null であってはなりません。- 戻り値:
- 指定された識別子を持つエンティティへの参照。
- 関連事項:
for details on when an exception is thrown.
getById
使用すべきではありません。インターフェースからコピーされた説明:JpaRepository
指定された識別子を持つエンティティへの参照を返します。JPA 永続性プロバイダーの実装方法によっては、これは常にインスタンスを返し、最初のアクセスでEntityNotFoundException
をスローする可能性が非常に高くなります。それらのいくつかは、無効な識別子をすぐに拒否します。- 次で指定:
- インターフェース
JpaRepository<T,
のID> getById
- パラメーター:
id
- null であってはなりません。- 戻り値:
- 指定された識別子を持つエンティティへの参照。
- 関連事項:
for details on when an exception is thrown.
getReferenceById
インターフェースからコピーされた説明:JpaRepository
指定された識別子を持つエンティティへの参照を返します。JPA 永続性プロバイダーの実装方法によっては、これは常にインスタンスを返し、最初のアクセスでEntityNotFoundException
をスローする可能性が非常に高くなります。それらのいくつかは、無効な識別子をすぐに拒否します。- 次で指定:
- インターフェース
JpaRepository<T,
のID> getReferenceById
- パラメーター:
id
- null であってはなりません。- 戻り値:
- 指定された識別子を持つエンティティへの参照。
- 関連事項:
for details on when an exception is thrown.
existsById
- 次で指定:
- インターフェース
CrudRepository<T,
のID> existsById
findAll
- 次で指定:
- インターフェース
CrudRepository<T,
のID> findAll
- 次で指定:
- インターフェース
ListCrudRepository<T,
のID> findAll
findAllById
- 次で指定:
- インターフェース
CrudRepository<T,
のID> findAllById
- 次で指定:
- インターフェース
ListCrudRepository<T,
のID> findAllById
findAll
- 次で指定:
- インターフェース
ListPagingAndSortingRepository<T,
のID> findAll
- 次で指定:
- インターフェース
PagingAndSortingRepository<T,
のID> findAll
findAll
- 次で指定:
- インターフェース
PagingAndSortingRepository<T,
のID> findAll
findOne
インターフェースからコピーされた説明:JpaSpecificationExecutor
指定されたSpecification
またはOptional.empty()
に一致する単一のエンティティが見つからない場合、それを返します。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のfindOne
- パラメーター:
spec
- null であってはなりません。- 戻り値:
- 決して null にはなりません。
findAll
インターフェースからコピーされた説明:JpaSpecificationExecutor
指定されたSpecification
に一致するすべてのエンティティを返します。Specification
が指定されていない場合は、<T>
に一致するすべてのエンティティが選択されます。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のfindAll
- パラメーター:
spec
- null でもかまいません。- 戻り値:
- 決して null にはなりません。
findAll
インターフェースからコピーされた説明:JpaSpecificationExecutor
- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のfindAll
- パラメーター:
spec
- null でもかまいません。pageable
- null であってはなりません。- 戻り値:
- 決して null にはなりません。
findAll
public Page<T> findAll(@Nullable Specification<T> spec, @Nullable Specification<T> countSpec, Pageable pageable) インターフェースからコピーされた説明:JpaSpecificationExecutor
- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のfindAll
- パラメーター:
spec
- null にすることができます。Specification
が指定されていない場合は、<T>
に一致するすべてのエンティティが選択されます。countSpec
- null にすることができます。Specification
が指定されていない場合は、<T>
に一致するすべてのエンティティがカウントされます。pageable
- null であってはなりません。- 戻り値:
- 決して null にはなりません。
findAll
インターフェースからコピーされた説明:JpaSpecificationExecutor
指定されたSpecification
およびSort
に一致するすべてのエンティティを返します。Specification
が指定されていない場合は、<T>
に一致するすべてのエンティティが選択されます。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のfindAll
- パラメーター:
spec
- null でもかまいません。sort
- null であってはなりません。- 戻り値:
- 決して null にはなりません。
exists
インターフェースからコピーされた説明:JpaSpecificationExecutor
データストアに、指定されたSpecification
と一致する要素が含まれているかどうかを確認します。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のexists
- パラメーター:
spec
- 存在チェックに使用するSpecification
は null であってはなりません。- 戻り値:
- データストアに指定された
Specification
に一致する要素が含まれている場合はtrue
、それ以外の場合はfalse
。
delete
インターフェースからコピーされた説明:JpaSpecificationExecutor
Specification
によって削除し、削除された行数を返します。この方法では、データベース削除操作に直接マップされる
Criteria API bulk delete
を使用します。永続化コンテキストは一括削除の結果と同期されません。CriteriaBuilder.createCriteriaDelete(Class)
はCriteriaQuery
を実装していないため、CriteriaQuery
、Specification.toPredicate(Root, CriteriaQuery, CriteriaBuilder)
は null になることに注意してください。Specification
が指定されていない場合は、<T>
に一致するすべてのエンティティが削除されます。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のdelete
- パラメーター:
spec
- 存在チェックに使用するSpecification
は null にできません。- 戻り値:
- 削除されたエンティティの数。
findBy
public <S extends T,R> R findBy(Specification<T> spec, FunctionSE<? super JpaSpecificationExecutor.SpecificationFluentQuery<S>, R> queryFunction) インターフェースからコピーされた説明:JpaSpecificationExecutor
クエリとその結果の型を定義するqueryFunction
を適用して、指定されたSpecification
に一致するエンティティを返します。queryFunction
で使用されるクエリオブジェクトは、findBy(…)
メソッド呼び出し内でのみ有効です。クエリがfindBy(…)
メソッド内で実行されるようにするには、クエリ関数がFluentQuery
オブジェクト自体ではなくクエリ結果を返す必要があります。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のfindBy
- パラメーター:
spec
- null であってはなりません。queryFunction
- 射影、並べ替え、結果型を定義するクエリ関数- 戻り値:
- 指定された仕様に一致するすべてのエンティティ。
findOne
- 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のfindOne
count
- 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のcount
exists
- 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のexists
findAll
- 次で指定:
- インターフェース
JpaRepository<T,
のID> findAll
- 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のfindAll
findAll
- 次で指定:
- インターフェース
JpaRepository<T,
のID> findAll
- 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のfindAll
findAll
- 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のfindAll
findBy
public <S extends T,R> R findBy(Example<S> example, FunctionSE<FluentQuery.FetchableFluentQuery<S>, R> queryFunction) - 次で指定:
- インターフェース
QueryByExampleExecutor<T>
のfindBy
count
public long count()- 次で指定:
- インターフェース
CrudRepository<T,
のID> count
count
インターフェースからコピーされた説明:JpaSpecificationExecutor
指定されたSpecification
が返すインスタンスの数を返します。Specification
が指定されていない場合は、<T>
に一致するすべてのエンティティがカウントされます。- 次で指定:
- インターフェース
JpaSpecificationExecutor<T>
のcount
- パラメーター:
spec
- インスタンスをカウントするSpecification
は null であってはなりません。- 戻り値:
- インスタンスの数。
save
- 次で指定:
- インターフェース
CrudRepository<T,
のID> save
saveAndFlush
インターフェースからコピーされた説明:JpaRepository
エンティティを保存し、変更を即座にフラッシュします。- 次で指定:
- インターフェース
JpaRepository<T,
のID> saveAndFlush
- パラメーター:
entity
- 保存するエンティティ。null であってはなりません。- 戻り値:
- 保存されたエンティティ
saveAll
- 次で指定:
- インターフェース
CrudRepository<T,
のID> saveAll
- 次で指定:
- インターフェース
ListCrudRepository<T,
のID> saveAll
saveAllAndFlush
インターフェースからコピーされた説明:JpaRepository
すべてのエンティティを保存し、変更を即座にフラッシュします。- 次で指定:
- インターフェース
JpaRepository<T,
のID> saveAllAndFlush
- パラメーター:
entities
- 保存するエンティティ。null であってはなりません。- 戻り値:
- 保存されたエンティティ
flush
インターフェースからコピーされた説明:JpaRepository
データベースに対するすべての保留中の変更をフラッシュします。- 次で指定:
- インターフェース
JpaRepository<T,
のID> flush
readPage
@DeprecatedSE protected Page<T> readPage(jakarta.persistence.TypedQuery<T> query, Pageable pageable, @Nullable Specification<T> spec) 使用すべきではありません。代わりにreadPage(TypedQuery, Class, Pageable, Specification)
を使用してください- パラメーター:
query
- null であってはなりません。spec
- null でもかまいません。pageable
- null であってはなりません。
readPage
protected <S extends T> Page<S> readPage(jakarta.persistence.TypedQuery<S> query, ClassSE<S> domainClass, Pageable pageable, @Nullable Specification<S> spec) - パラメーター:
query
- null であってはなりません。domainClass
- null であってはなりません。spec
- null でもかまいません。pageable
- null でもかまいません。
getQuery
protected jakarta.persistence.TypedQuery<T> getQuery(@Nullable Specification<T> spec, Pageable pageable) 指定されたSpecification
から新しいTypedQuery
を作成します。- パラメーター:
spec
- null でもかまいません。pageable
- null であってはなりません。
getQuery
protected <S extends T> jakarta.persistence.TypedQuery<S> getQuery(@Nullable Specification<S> spec, ClassSE<S> domainClass, Pageable pageable) 指定されたSpecification
から新しいTypedQuery
を作成します。- パラメーター:
spec
- null でもかまいません。domainClass
- null であってはなりません。pageable
- null であってはなりません。
getQuery
- パラメーター:
spec
- null でもかまいません。sort
- null であってはなりません。
getQuery
protected <S extends T> jakarta.persistence.TypedQuery<S> getQuery(@Nullable Specification<S> spec, ClassSE<S> domainClass, Sort sort) - パラメーター:
spec
- null でもかまいません。domainClass
- null であってはなりません。sort
- null であってはなりません。
getCountQuery
@DeprecatedSE protected jakarta.persistence.TypedQuery<LongSE> getCountQuery(@Nullable Specification<T> spec) 使用すべきではありません。代わりにgetCountQuery(Specification, Class)
をオーバーライドします指定されたSpecification
の新しいカウントクエリを作成します。- パラメーター:
spec
- null でもかまいません。
getCountQuery
protected <S extends T> jakarta.persistence.TypedQuery<LongSE> getCountQuery(@Nullable Specification<S> spec, ClassSE<S> domainClass) 指定されたSpecification
の新しいカウントクエリを作成します。- パラメーター:
spec
- null でもかまいません。domainClass
- null であってはなりません。
getQueryHints
getQueryHintsForCount
カウントクエリの現在のCrudMethodMetadata
に関するクエリヒントを含むQueryHints
を返します。
getCountQuery(Specification, Class)
をオーバーライドします